Reputation: 329
Using htaccess, how can I change the url "http://www.website.com/abc/..." to "http://www.website.com/xyz/..." so it acts as a redirect to the same filename/directory structure after "xyz" as it did after "abc".
Upvotes: 0
Views: 2264
Reputation: 165188
RewriteRule ^abc/(.*)$ /xyz/$1 [R=302,L,QSA]
This will redirect example.com/abc/pink-kitten
to example.com/xyz/pink-kitten
(or example.com/abc/
to example.com/xyz/
) but will not do anything if trailing slash after the folder name is missing (i.e. example.com/abc
will not be redirected). If you need the last case as well then you will need to use separate rule for that.
You can change redirect code [R=302]
to another if required (e.g. 301 Permanent Redirect).
Upvotes: 1