nginx conditional rewrite issue

无人久伴 提交于 2021-02-08 07:51:03

问题


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

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

This block rewrites /first to /?system=first, /second to /?system=second, etc.

However, this rewrite should not be done for /six and /nine. How could I write this condition?


回答1:


Fixed with regex

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


来源:https://stackoverflow.com/questions/45526436/nginx-conditional-rewrite-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!