I want to redirect url using htaccess file from project root folder.
I can easily redirect url like www.xyz.com/ar/contact to www.xyz.com/contact using this
Redirect 301 /ar/contact/ /contact/
but how to redirect url like this
www.xyz.com/ar/shop/xyz.html to www.xyz.com/shop/xyz.html
I have tried this
Redirect 301 /ar/shop/^(.*)$ /shop/$1
Redirect /ar/shop/^(.*)$ /shop/$1 [R=301,L]
Redirect ^/ar/shop/(.*) /shop/$1
but it did’t work.
2
Answers
Could you please try following. Written and tested with shown samples only.
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/
.This will redirect all URIs starting with
/ar/shop/
to/shop/
. forexample/ar/shop/foobar
will get redirected to/shop/foobar
> .