url-rewrite - nginx rewrite冲突解决

【字号: 日期:2022-07-10浏览:30作者:雯心

问题描述

想要实现的效果是abc.com/hello => abc.com/article.php?link=helloabc.com/en/ => abc.com/index.php?lang=enabc.com/en/hello => abc.com/article.php?link=hello&lang=en目前的写法是location / {

try_files $uri $uri/ =404; if (!-e $request_filename){rewrite ^/(.*)$ /article.php?link=$1 last; }}location /en/ { rewrite index index.php?lang=en; rewrite ^/en/(.*)$ /article.php?link=$1&lang=en last;}

目前的问题是abc.com/hello是没问题的,abc.com/en/hello也是没问题的,abc.com/en/会被当成hello那样解析出现错误

问题解答

回答1:

/en/ 也作为一个rewrite规则来做

相关文章: