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是不匹配帶問號的部分的