I have to Rewrite massive number of URLs e.g: FROM: http://www.lespoulettes-bijoux.fr/produit2.asp?id_produit=8489 TO: http://www.lespoulettes-bijoux.fr/colliers-femme-createur-fantaisie/femme-collier-ras-de-cou-fils-d-argent-et-6-perles-blanches-et-grises-10005.html
So I selected to do a RewriteMap cause my URL doesn't have the same ID to match with.
So I declared my RewriteMap who is loking like that:
8489 http://www.lespoulettes-bijoux.fr/colliers-femme-createur-fantaisie/femme-collier-ras-de-cou-fils-d-argent-et-6-perles-blanches-et-grises-10005.html
In my .htacess: I wanted to convert my URL to transform my GET parameter (id_produit) into an interal id to git it after in my ReWriteMap.
The Problem: I have An Error 500 while converting my URL and I dont know the right syntax to switch after convert it:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^id_produit\=(.+)$
RewriteRule (.*) /$1/id=%1 <== HERE 500 Internal Server Error
#RewriteRule ^/id_produit.asp/(.*)$ ${map_product:$1} [R]
To resume: I want to switch 'www.exemple.com/produit2.asp?id_produit=8489' into www.exemple.com/produit2.asp/id=8489 and send the id to my RewriteMap to redirect to the Right URL.
Thanks for your help!
The problem here is probably:
that is causing a loop. The rewrite engine loops so after this is rewritten, the result will still match this rule and thus get rewritten again. Try adding a
?to the end so that the query string is removed:Additionally, yuo need to remove the leading slashes in the regex. Request URI's have their leading slashes stripped off in rules that are per-directory based (like in an htaccess file) so the regex needs to look like:
And this rule needs to be before your other rule.