Reputation: 25
This is my input url
site.com/?product-43049-keep-kids-filet-children-shoe
I want it to redirect into this
site.com/productDetail.php?id=43049
I have already tried the following code but it doesn't work:
RewriteRule ?product-(.*)-(.*) productDetail?id=$1 [NC,QSA,L]
Upvotes: 1
Views: 475
Reputation: 786289
You cannot match query string in RewriteRule
you need to use RewriteCond
with %{QUERY_STRING}
variable:
Try this code:
RewriteCond %{QUERY_STRING} ^product-([0-9]+)- [NC]
RewriteRule ^/?$ /productDetail.php?id=%1 [L,QSA]
Upvotes: 1