RedirectPermanent sans transmettre la query string source (paramètres source)

Ce post car j’ai été confronté à un problème en utilisant l’instruction RedirectPermanent dans un fichier .htaccess.

Le but était de rediriger une url du type : http://www.old-exemple.com/index.php?id=33 vers une url du type http://www.new-exemple.com/toto.php
Ne souhaitant pas utiliser le mod réécriture d’url d’Apache, j’ai souhaité utilisé l’instruction RedirectPermanent.

RedirectPermanent index.php?id=33 http://www.new-exemple.com/toto.php

Le problème est qu’Apache redirige l’internaute vers l’url : http://www.new-exemple.com/index.php?id=33

la query string source a été transmise à l’url cible. On ne peut pas modifier ce comportement car Apache active automatique le mode QSA pour le RedirectPermanent.

La seule solution est de passer par de l’url rewriting :

RewriteCond %{QUERY_STRING} ^p_id=74$
RewriteRule ^index\.php$ http://www.new-exemple.com/toto.php? [R=301,L]

You can leave a response, or trackback from your own site.

Leave a Reply

Powered by WordPress | iCellPhoneDeals.com has the best cell phone Deals. | Thanks to Upgrade Sprint Phone, MMO Games and Conveyancing