如何将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屋!
查看全文