how to redirect url using custom logic in .htaccess?

Viewed 62
2 Answers

Could you please try following. Written and tested with shown samples only.

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/ar/(.*)/? [NC]
RewriteRule ^(.*) /%1 [R=301,NE,L]

You can not use a regex based pattern in Redirect directive. If you want to redirect everything that comes after /ar/shop/ to /shop/ then just use a static pattern /ar/shop/ .

Redirect 301 /ar/shop/ /shop/

This will redirect all URIs starting with /ar/shop/ to /shop/ . forexample /ar/shop/foobar will get redirected to /shop/foobar > .

Related