0

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?

1

You could try:

RedirectMatch (^/categories/washroom/)(.*) http://www.mysite.com/shop/categories/washroom/$1

Does that work?

2

Reverse your logic:

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/shop
RewriteRule ^/(.*)$ http://%{SERVER_NAME}/shop/$1 [L,R]
  • Thanks for your reply, I have solved my original problem with the answer above however your reply will be useful for future reference. – user43652 Jun 7 '10 at 6:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.