0

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".

1 Answer 1

1
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).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.