Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have recently moved all the content on my website from being in the directory to being in the root directory. This means that now I need to redirect any request to visit a page with the /shop directory back to the same page in the root directory eg.


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

The closest thing to a solution that I have found so far is the following code

#RedirectMatch ^/shop/.*

however this redirects all pages back to the homepage instead of to the relevant matching page without the /shop.

Can someone please point me in the right direction, or if this has already been answered in here can you please post the link to the answer.

share|improve this question
up vote 4 down vote accepted
RedirectMatch (^/shop/)(.*)$2
share|improve this answer
Thanks for your answer. This works perfectly. – user43652 May 19 '10 at 23:28
Pleasure. Unfortuantely rewrite rules are about all I know how to do with regular expressions! – Mark Henderson May 19 '10 at 23:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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