I have a .htaccess rule that goes like this
我有一个像这样的.htaccess规则
RewriteRule ^account/(.*) myaccount.php?p=$1 [NC,L]
This works fine for URLs like https://www.example.com/account/abcd
. However, now I want to pass query parameters to this URL, something like https://www.example.com/account/abcd?ab=1&cd=2
.
这适用于https://www.example.com/account/abcd等网址。但是,现在我想将查询参数传递给此URL,例如https://www.example.com/account/abcd?ab=1&cd=2。
Can't figure out the exact .htaccess
rule that can accommodate this. Any pointers?
无法弄清楚可以容纳这个的确切.htaccess规则。有什么指针吗?
1 个解决方案
#1
2
Use:
RewriteRule ^account/(.*) myaccount.php?p=$1 [QSA,NC,L]
With QSA:
QSA|qsappend
When the replacement URI contains a query string, the default behavior of RewriteRule is to discard the existing query string, and replace it with the newly generated one. Using the [QSA] flag causes the query strings to be combined.
http://httpd.apache.org/docs/current/rewrite/flags.htmlQSA | qsappend当替换URI包含查询字符串时,RewriteRule的默认行为是丢弃现有查询字符串,并将其替换为新生成的查询字符串。使用[QSA]标志会导致组合查询字符串。 http://httpd.apache.org/docs/current/rewrite/flags.html
#1
2
Use:
RewriteRule ^account/(.*) myaccount.php?p=$1 [QSA,NC,L]
With QSA:
QSA|qsappend
When the replacement URI contains a query string, the default behavior of RewriteRule is to discard the existing query string, and replace it with the newly generated one. Using the [QSA] flag causes the query strings to be combined.
http://httpd.apache.org/docs/current/rewrite/flags.htmlQSA | qsappend当替换URI包含查询字符串时,RewriteRule的默认行为是丢弃现有查询字符串,并将其替换为新生成的查询字符串。使用[QSA]标志会导致组合查询字符串。 http://httpd.apache.org/docs/current/rewrite/flags.html