How do you redirect pages from a directory to a subdirectory?

Posted by kezzman11 on Server Fault See other posts from Server Fault or by kezzman11
Published on 2010-06-06T23:26:56Z Indexed on 2010/06/06 23:32 UTC
Read the original article Hit count: 293

I had recently moved all the content on my website from being in the www.mysite.com/shop directory to being in the root directory. This means that I needed to redirect any request to visit a page with the /shop directory back to the same page in the root directory eg.

www.mysite.com/shop/categories/washroom

to

www.mysite.com/categories/washroom

This needed to happen with all pages in my site that were previously using the /shop directory.

I was given a solution on here which was:

RedirectMatch (^/shop/)(.*) http://www.mysite.com/$2

and it works perfectly however now I have had to switch back to using our old version of our software which is located at the /shop directory so I need the complete opposite redirect now eg.

www.mysite.com/categories/washroom

to

www.mysite.com/shop/categories/washroom

Can anyone help me please?

© Server Fault or respective owner

Related posts about .htaccess

Related posts about redirect