全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 4198|回复: 21

[nginx] 301重定向问题

[复制链接]
发表于 2010-5-30 11:04:11 | 显示全部楼层 |阅读模式
server {
server_name xxx.com ;
rewrite ^(.*) http://www.xxx.com$1 permanent;
}
上面这段代码放在最下面
server {
    server_name xxx.com www.xxx.com;

    if ($host != 'www.xxx.com' ) {
        rewrite ^/(.*)$ http://www.xxx.com/$1 permanent;
    }
    ...
}

上面的我都在/usr/local/nginx/conf/vhost下设置后重启VPS,咋都没效果
发表于 2010-5-30 11:16:50 | 显示全部楼层
 楼主| 发表于 2010-5-30 11:20:05 | 显示全部楼层
原帖由 美国VPS 于 2010-5-30 11:16 发表
http://www.google.com.hk/search? ... mp;oq=&gs_rfai=


permanent 改成 last

改了没效果
发表于 2010-5-30 11:24:08 | 显示全部楼层
谷姐一下救OK了
 楼主| 发表于 2010-5-30 11:28:30 | 显示全部楼层
全试了,论坛也搜索了不知道问题出在那里
server
        {
                listen       80;
                server_name bailongjun.com www.bailongjun.com;
                index index.html index.htm index.php default.html default.htm default.php;
                root  /home/wwwroot/bailongjun;

                include emlog.conf;

                location ~ .*\.(php|php5)?$
                        {
                                fastcgi_pass  unix:/tmp/php-cgi.sock;
                                fastcgi_index index.php;
                                include fcgi.conf;
                        }

                location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
                        {
                                expires      30d;
                        }

                location ~ .*\.(js|css)?$
                        {
                                expires      12h;
                        }

                access_log off;
        }
server {
server_name bailongjun.com ;
rewrite ^(.*) http://www.bailongjun.com$1 last;
}

上面是我目前的代码
发表于 2010-5-30 12:02:04 | 显示全部楼层

回复 1# 的帖子

nginx -t 看看有没有什么错误
 楼主| 发表于 2010-5-30 12:03:48 | 显示全部楼层
-bash: nginx: command not found

[ 本帖最后由 白龙君 于 2010-5-30 12:05 编辑 ]
发表于 2010-5-30 12:12:31 | 显示全部楼层
/usr/local/nginx/sbin/nginx -t 检测

killall -HUP nginx 重启

楼主没重启吧
发表于 2010-5-30 12:13:00 | 显示全部楼层
/usr/local/nginx/conf/vhost

nginx.conf 里 有

include vhost/*.conf ;

吗?
发表于 2010-5-30 12:14:08 | 显示全部楼层

回复 7# 的帖子

到你的nginx安装目录下

/usr/local/nginx/sbin/nginx -t
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-5-17 02:13 , Processed in 0.063852 second(s), 8 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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