nginx条件重写问题

时间:2017-08-05 21:06:24

标签: mod-rewrite nginx

location / {
    try_files $uri $uri/ /index.php?$args =404;

    rewrite ^/(\w+)$ /?system=$1 break;
}

此块会将/first重写为/?system=first,将/second重写为/?system=second等。

但是,不应对/six/nine进行此重写。我怎么能写这个条件?

1 个答案:

答案 0 :(得分:1)

使用正则表达式修复

rewrite ^/((?!six|nine)\b\w+$) /?system=$1 break;