歡迎您光臨本站 註冊首頁

nginx中location不包含語法問題

←手機掃碼閱讀     火星人 @ 2014-03-03 , reply:0

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:35 編輯

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

rewrite  ^/(.*)/(.*?).shtml$ /shtml/$1/$2.shtml last; 這句對不對你要自己研究下rewrite是不匹配帶問號的部分的

[火星人 ] nginx中location不包含語法問題已經有710次圍觀

http://coctec.com/docs/service/show-post-847.html