我不知道如何编写涉及原始网址(在我的.htaccess中)中的参数的重写规则


I don't know how to write a Rewrite Rule that involves a parameter in the original url (in my .htaccess)

我正在尝试重写这个...

http://site.com/product.php?pProductID=ABC-PRD-CODE

http://site.com/front/product.php?pStyleId=ABC-PRD-CODE

到目前为止,我已经在我的htaccess中尝试过这个,但它似乎是原因和错误,只是反弹回索引页面。

RewriteRule ^product'.php'?pProductID=(.*) front/product.php?pStyleId=$1

有人可以告诉我我做错了什么吗?您是否需要查看htaccess的其余部分,以查看是否有其他内容干扰了此规则?

查询字符串不包含在重写规则中。为此,您必须使用RewriteCons。 %1将替换为重写条件的第一个捕获组。有关详细信息,请参阅文档。

RewriteCond %{QUERY_STRING} ^pProductID=(.*)$
RewriteRule ^product'.php$ front/product.php?pStyleId=%1 [L]