nginx条件重写问题 [英] nginx conditional rewrite issue
本文介绍了nginx条件重写问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
location / {
try_files $uri $uri/ /index.php?$args =404;
rewrite ^/(\w+)$ /?system=$1 break;
}
此块将/first
重写为/?system=first
,将/second
重写为/?system=second
等
This block rewrites /first
to /?system=first
, /second
to /?system=second
, etc.
但是,对于/six
和/nine
不应该进行这种重写.我怎么能写这个条件?
However, this rewrite should not be done for /six
and /nine
. How could I write this condition?
推荐答案
用正则表达式修复
rewrite ^/((?!six|nine)\b\w+$) /?system=$1 break;
这篇关于nginx条件重写问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文