spouter 发表于 2012-04-09 19:32

nginx中location不包含语法问题

希望实现url访问路径根目录不包含/inc/,用下面写法不能实现,求教一下。
location ^~ ^/inc/{
         rewrite^/(.*)/(.*?).shtml$ /shtml/$1/$2.shtml last;
}
如果改为
location !~ ^/inc/{
         rewrite^/(.*)/(.*?).shtml$ /shtml/$1/$2.shtml last;
}
直接语法验证不过去。

失落之岛 发表于 2012-04-10 16:32

本帖最后由 失落之岛 于 2012-04-10 16:35 编辑

location / {
      if ( $request !~ /inc ) {
         rewrite^/(.*)/(.*?).shtml$ /shtml/$1/$2.shtml last;
      }
}

rewrite^/(.*)/(.*?).shtml$ /shtml/$1/$2.shtml last; 这句对不对你要自己研究下rewrite是不匹配带问号的部分的
页: [1]
查看完整版本: nginx中location不包含语法问题