mod-rewrite,从URL1参数传递给URL2参数、rewrite、mod

2023-09-02 09:44:08 作者:浪漫,她,我,爱

我试图重写以下网址

test.php?par1=foo&par2=bar

进入...

Into...

newtest.php?hidden_par=blah&par1=foo&par2=bar

我有这个规则,不工作:

I have this rule, that does not work:

RewriteRule ^test.php??(.*?)$ newtest.php?hiden_par=blah&$1 [L]

难道这样做使用的RewriteCond还是其他什么东西?提前(比方说,可以这样做吗?),谢谢。

Could this be done using RewriteCond or something else? (say, could this be done ?), thanks in advance.

推荐答案

您可能想要的东西,如 QSA (查询字符串附加)标志,这将导致剩余查询字符串的被正确地附加到重写的URL的结尾。

You probably want something like the QSA ("query string append") flag, which causes the remainder of the query string to be properly appended onto the end of the rewritten URL.

例如:

^test.php test.php?hidden=value [L,QSA]