.htaccess get after ? (Question Mark)



这是我的输入url

site.com/?product-43049-keep-kids-filet-children-shoe

我希望它重定向到这个

site.com/productDetail.php?id=43049

我已经尝试了以下代码,但它不起作用:

RewriteRule ?product-(.*)-(.*) productDetail?id=$1 [NC,QSA,L]

您无法匹配RewriteRule中的查询字符串,您需要将RewriteCond%{QUERY_STRING}变量使用:

尝试此代码:

RewriteCond %{QUERY_STRING} ^product-([0-9]+)- [NC]
RewriteRule ^/?$ /productDetail.php?id=%1 [L,QSA]

最新更新