mojave 发表于 2009-10-12 20:16:20

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
我看别人都这样插入静态规则的...怎么就不能重复呢

mojave 发表于 2009-10-12 20:42:04

yc002t 严重求救

cpuer 发表于 2009-10-12 21:09:26

回复 2# 的帖子

我看下,稍等 :)

cpuer 发表于 2009-10-12 21:17:14

回复 1# 的帖子

把location / {
                        stub_status on;
                        access_log   off;
                                 }

这段删除掉。或者注释掉

#location / {
                        #stub_status on;
                        #access_log   off;
                              # }

zyypp 发表于 2009-10-12 21:23:33

回复 1# 的帖子

你怎么 2个 location / 啊 重复了 人才啊

mojave 发表于 2009-10-12 21:26:59

回复 4# 的帖子

我不知道注释掉会不会出现错误,没敢动yc022t 现在就改

cpuer 发表于 2009-10-12 21:29:10

回复 6# 的帖子

注销了就好了,不然就会提示重复出错的。

而且你这个是做站的,就不能放stub_status on 了。

zyypp 发表于 2009-10-12 22:00:27

你可以把 status 定义成为一个 虚拟目录

mojave 发表于 2009-10-12 22:01:20

回复 7# 的帖子

还是不行,注释了测试没有语法错误了,但是 kill -HUP `cat /usr/local/nginx/logs/nginx.pid`之后,依然无法静态....怪事,是不是没有在编译时候加入准许rewrite的参数....

cpuer 发表于 2009-10-12 22:07:26

回复 9# 的帖子

host1.moltown.com没有discuz论坛呀 :o

server_namehost1.moltown.com; 绑定的是这个域名。
页: [1] 2 3 4 5 6
查看完整版本: nginx静态规则这样添加为何不行,该如何改