多IP多域名使用301后有问题
centos 6 lnmp环境 默认IP:23.xx.xx.88我在根目录绑定域名 host.xxx.com
listen 80;
server_name host.xxx.com;
然后建立虚拟主机 www.yyy.com
listen 23.xx.xx.88:80;
server_name www.yyy.com yyy.com;
if ( $host != 'www.yyy.com' ) {
rewrite ^/(.*)$ http://www.yyy.com/$1 permanent;
}
然后再建立虚拟主机 www.zzz.com
listen 23.xx.xx.89:80;
server_name www.zzz.com zzz.com;
if ( $host != 'www.zzz.com' ) {
rewrite ^/(.*)$ http://www.zzz.com/$1 permanent;
}
然后我访问host.xxx.com回自动跳转到www.yyy.com怎么回事呢?求军哥指教 没有人指点下吗 ?我自己顶下吧 listen不需要指定IP
host.xxx.com自动跳转到www.yyy.com 可能是host哪个虚拟主机的配置有问题 /usr/local/nginx/sbin/nginx -t 测试看看 那个是host.xxx.com 是根域就是安装lnmp的时候的都没动
另外我主机上有多个IP不需要指定IP吗?
回复 3# 的帖子
nginx.conf.........
server
{
listen 80;
server_name host.dz58.net;
if ( $host != 'host.dz58.net' ) {
rewrite ^/(.*)$ http://host.dz58.net/$1 permanent;
}
index index.html index.htm index.php;
root/home/wwwroot;
........
vhost/xmm75.com.conf
............
server
{
listen 23.88.2.224:80;
server_name xmm75.com www.xmm75.com;
if ( $host = 'xmm75.com' ){
rewrite ^/(.*)$ http://www.xmm75.com/$1 permanent;
}
index index.html index.htm index.php default.html default.htm default.php;
root/home/wwwroot/xmm75;
.......
vhost/xmm56.com.conf
...........
server
{
listen 23.88.2.224:80;
server_name xmm56.com www.xmm56.com;
if ( $host = 'xmm56.com' ){
rewrite ^/(.*)$ http://www.xmm56.com/$1 permanent;
}
index index.html index.htm index.php default.html default.htm default.php;
root/home/wwwroot/xmm56;
...........
代码就是上面这样的 但是 我直接IP访问 显示的是 www.xmm56.com 这个网站的内容
而访问www.xmm56.com 却提示无法打开,或者链接被重置。
真的很郁闷啊! 虚拟主机配置里listen不需要指定IP
贴出的配置里看没问题
执行/usr/local/nginx/sbin/nginx -t 测试配置看看
页:
[1]