全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

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

nginx静态规则这样添加为何不行,该如何改

[复制链接]
发表于 2009-10-12 20:16:20 | 显示全部楼层 |阅读模式
server
        {
                listen  80;
                server_name  host1.moltown.com;

                location / {
                        stub_status on;
                        access_log   off;
                                 }

location / {
            rewrite ^/archiver/((fid|tid)-[\w\-]+\.html)$ /archiver/index.php?$1 last;
            rewrite ^/forum-([0-9]+)-([0-9]+)\.html$ /forumdisplay.php?fid=$1&page=$2 last;
            rewrite ^/thread-([0-9]+)-([0-9]+)-([0-9]+)\.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/$1  permanent;
  }
  
        rewrite ^/(post|record|sort|author|page)-([0-9]+)\.html$ /index.php?$1=$2;
        rewrite ^/tag-(.+)\.html$ /index.php?tag=$1;
            }

     }

测试出现[emerg]: duplicate location "/" in /usr/local/nginx/conf/nginx.conf:103
configuration file /usr/local/nginx/conf/nginx.conf test failed
我看别人都这样插入静态规则的...怎么就不能重复呢
 楼主| 发表于 2009-10-12 20:42:04 | 显示全部楼层
严重求救
发表于 2009-10-12 21:09:26 | 显示全部楼层

回复 2# 的帖子

我看下,稍等
发表于 2009-10-12 21:17:14 | 显示全部楼层

回复 1# 的帖子

把  location / {
                        stub_status on;
                        access_log   off;
                                 }

这段删除掉。或者注释掉

#location / {
                        #stub_status on;
                        #access_log   off;
                                # }
发表于 2009-10-12 21:23:33 | 显示全部楼层

回复 1# 的帖子

你怎么 2个 location / 啊 重复了 人才啊
 楼主| 发表于 2009-10-12 21:26:59 | 显示全部楼层

回复 4# 的帖子

我不知道注释掉会不会出现错误,没敢动 现在就改
发表于 2009-10-12 21:29:10 | 显示全部楼层

回复 6# 的帖子

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

而且你这个是做站的,就不能放stub_status on 了。
发表于 2009-10-12 22:00:27 | 显示全部楼层
你可以把 status 定义成为一个 虚拟目录
 楼主| 发表于 2009-10-12 22:01:20 | 显示全部楼层

回复 7# 的帖子

还是不行,注释了测试没有语法错误了,但是 kill -HUP `cat /usr/local/nginx/logs/nginx.pid`之后,依然无法静态....怪事,是不是没有在编译时候加入准许rewrite的参数....
发表于 2009-10-12 22:07:26 | 显示全部楼层

回复 9# 的帖子

host1.moltown.com  没有discuz论坛呀

server_name  host1.moltown.com; 绑定的是这个域名。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-20 18:55 , Processed in 0.062535 second(s), 10 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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