.htaccess htaccess重定向到新参数

.htaccess htaccess重定向到新参数,.htaccess,mod-rewrite,url-rewriting,.htaccess,Mod Rewrite,Url Rewriting,我希望html重定向到不同的php和参数,php位于子目录中,例如,从/subdir/index.php?thread=23 post=12/subdir/到showthread.php?topic=23&topic=12。但这不起作用: RewriteRule ^/test/index\.php?thread=(.*)-post=(.*)$ /test/showthread.php?topic=$1&topic=$2 [R] 有什么建议吗 提前感谢您无法匹配重写规则中的查询字符串。您

我希望html重定向到不同的php和参数,php位于子目录中,例如,从/subdir/index.php?thread=23 post=12/subdir/到showthread.php?topic=23&topic=12。但这不起作用:

RewriteRule ^/test/index\.php?thread=(.*)-post=(.*)$ /test/showthread.php?topic=$1&topic=$2 [R]
有什么建议吗


提前感谢

您无法匹配
重写规则中的查询字符串
。您需要在
RewriteCond
中匹配
%{QUERY\u STRING}
变量,并使用
%
反向引用:

RewriteCond %{QUERY_STRING} ^thread=([^-]+)-post=(.*)$
RewriteRule ^/?test/index\.php$ /test/showthread.php?topic=%1&topic=%2 [L,R]
请注意,您的规则将两件事映射到
主题
查询字符串参数