i would like simply to create a 301 redirect, but my code does’nt work and returns a beautiful 404 page (-_-).
I think the problem is the “?” in the from url, i tried to escape it but it doesn’t work anymore.
RewriteRule ^produit.php?PDT_ID=473 /product.php?id_product=210 [R=301]
Thanks to take a look
It’s a common mistake. As the docs say, to test for things in the query string, you need to use a RewriteCond directive, like this:
Which means “if the query string matches the pattern ‘PDT_ID=473’, and the pattern matches the uri, then rewrite”. Note that you might want to make the rewriteCond’s regex more foolproof to ensure it won’t match things like APDT_ID=4735 as well, but this should get you started.