url-rewrite - nginx rewrite冲突解决
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-05-16 17:22:08
0
1
488

想要实现的效果是
abc.com/hello => abc.com/article.php?link=hello
abc.com/en/ => abc.com/index.php?lang=en
abc.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= last;
    }
}
location /en/ {
    rewrite index index.php?lang=en;
    rewrite ^/en/(.*)$ /article.php?link=&lang=en last;        
}

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

曾经蜡笔没有小新
曾经蜡笔没有小新

全部回复(1)
刘奇

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

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!