redirect url using .htaccess [R=301,L]

Jignesh Mesvaniya picture Jignesh Mesvaniya · Mar 28, 2013 · Viewed 20.4k times · Source

i want to redirect page url using .htaccess [R=301]

original url : http://www.encros.fr/la-boutique-encros/recharge-toner

redirect url : http://www.encros.fr/recharge-toner

anybody can help me ?

Answer

Marc Audet picture Marc Audet · Mar 28, 2013

You need something like this in your .htaccess file:

RewriteEngine  on
RewriteRule    ^/la-boutique-encros/recharge-toner$  /recharge-toner  [R=301,L]

The [R=301] flag sets the return code. The [L] flag prevents other rules from being applied to this specific rewrite.

References:
About rewrite: http://httpd.apache.org/docs/2.4/rewrite/remapping.html

About the rewrite flags: http://httpd.apache.org/docs/2.4/rewrite/flags.html