nginx静态规则这样添加为何不行,该如何改
server{
listen80;
server_namehost1.moltown.com;
location / {
stub_status on;
access_log off;
}
location / {
rewrite ^/archiver/((fid|tid)-[\w\-]+\.html)$ /archiver/index.php?$1 last;
rewrite ^/forum-(+)-(+)\.html$ /forumdisplay.php?fid=$1&page=$2 last;
rewrite ^/thread-(+)-(+)-(+)\.html$ /viewthread.php?tid=$1&extra=page%3D$3&page=$2 last;
rewrite ^/space-(username|uid)-(.+)\.html$ /space.php?$1=$2 last;
rewrite ^/tag-(.+)\.html$ /tag.php?name=$1 last;
break;
}
if ($host != 'moltown.com/my' ) {
rewrite^/(.*)$http://moltown.com/my/$1permanent;
}
rewrite ^/(post|record|sort|author|page)-(+)\.html$ /index.php?$1=$2;
rewrite ^/tag-(.+)\.html$ /index.php?tag=$1;
}
}
测试出现: duplicate location "/" in /usr/local/nginx/conf/nginx.conf:103
configuration file /usr/local/nginx/conf/nginx.conf test failed
我看别人都这样插入静态规则的...怎么就不能重复呢 yc002t 严重求救
回复 2# 的帖子
我看下,稍等 :)回复 1# 的帖子
把location / {stub_status on;
access_log off;
}
这段删除掉。或者注释掉
#location / {
#stub_status on;
#access_log off;
# }
回复 1# 的帖子
你怎么 2个 location / 啊 重复了 人才啊回复 4# 的帖子
我不知道注释掉会不会出现错误,没敢动yc022t 现在就改回复 6# 的帖子
注销了就好了,不然就会提示重复出错的。而且你这个是做站的,就不能放stub_status on 了。 你可以把 status 定义成为一个 虚拟目录
回复 7# 的帖子
还是不行,注释了测试没有语法错误了,但是 kill -HUP `cat /usr/local/nginx/logs/nginx.pid`之后,依然无法静态....怪事,是不是没有在编译时候加入准许rewrite的参数....回复 9# 的帖子
host1.moltown.com没有discuz论坛呀 :oserver_namehost1.moltown.com; 绑定的是这个域名。