如何将 mod_rewrite(QSA 选项)转换为 Nginx 等效项? [英] How do I convert mod_rewrite (QSA option) to Nginx equivalent?
本文介绍了如何将 mod_rewrite(QSA 选项)转换为 Nginx 等效项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望将以下 mod_rewrite
规则转换为 Nginx 等效项:
I'm looking to convert the following mod_rewrite
rule to the Nginx equivalent:
RewriteRule ^foo/(.*)$ /bar/index.php?title=$1 [PT,L,QSA]
RewriteRule ^foo/*$ /bar/index.php [L,QSA]
到目前为止我有:
rewrite ^foo/(.*)$ /bar/index.php?title=$1&$query_string last;
rewrite ^foo/?$ /bar/index.php?$query_string break;
问题是(我认为!)没有附加查询字符串.我还没有找到将 QSA
参数移植到 Nginx 的方法.
The problem is (I think!) that the query string doesn't get appended. I haven't found a way to port the QSA
argument to Nginx.
推荐答案
这些重写规则使脚本能够正常工作:
These rewrite rules made the scripts work:
rewrite ^/foo/([^?]*)(?:?(.*))? /bar/index.php?title=$1&$2;
rewrite ^/foo /bar/index.php;
这篇关于如何将 mod_rewrite(QSA 选项)转换为 Nginx 等效项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文