VPS侦探论坛

 找回密码
 注册
查看: 5423|回复: 5

多IP多域名使用301后有问题

[复制链接]
发表于 2013-9-14 12:36:07 | 显示全部楼层 |阅读模式

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  怎么回事呢?求军哥指教
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2013-9-14 13:00:09 | 显示全部楼层


没有人指点下吗 ?  我自己顶下吧
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2013-9-14 14:47:01 | 显示全部楼层

listen不需要指定IP

host.xxx.com  自动跳转到www.yyy.com 可能是host哪个虚拟主机的配置有问题 /usr/local/nginx/sbin/nginx -t 测试看看
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2013-9-14 16:25:34 | 显示全部楼层



那个是host.xxx.com 是根域  就是安装lnmp的时候的  都没动   

另外我主机上有多个IP  不需要指定IP吗?
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2013-9-14 16:34:50 | 显示全部楼层

回复 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 却提示无法打开,或者链接被重置。
真的很郁闷啊!

军哥运维代购:http://shop63846532.taobao.com/

发表于 2013-9-14 20:05:32 | 显示全部楼层

虚拟主机配置里listen不需要指定IP
贴出的配置里看没问题
执行/usr/local/nginx/sbin/nginx -t 测试配置看看
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-9-25 01:16 , Processed in 0.026548 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表