I had an e-commerce website hosted on http://mydomain.com/beta for more than a year, eventually I decided to move the website to root http://mydomain.com

I had done quite a lot of link postings to forums etc, when my site used to be hosted in the sub-dir /beta.

Is there a way to do a mod_rewrite by which all the old links that I have posted do not return as broken links, since now longer the site is hosted in /beta and is now hosted on the site root.

I did read that mod_rewrite can help resolve this issue, but also read about that this has to be done with care. Just a tip that this site is using friendly URL.

2 Answers 2


The rules below will redirect (301, permanent redirect -- will change address in URL bar as well) all incoming requests from http://www.example.com/beta/ to http://www.example.com/

# activate rewrite engine
RewriteEngine on
RewriteBase /

# redirect from /beta/ to /
RewriteRule ^beta/(.*)$ http://www.example.com/$1 [R=301,L,QSA]

If you need just rewrite (so URL stays the same in browser's adderss bar -- i.e. still contains /beta/) then replace last line by this:

RewriteRule ^beta/(.*)$ /$1 [L,QSA]

There is no need to overcomplicate matters, the one 'redirect' line will deal with everything in your sub directories and do the 301 thing:

Redirect permanent /beta /

Your Answer

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

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