Mobile app version of vmapp.org
Login or Join
Turnbaugh106

: URL rewrite to fix broken links into a subdirectory -- subdirectory was moved to the root directory I had an e-commerce website hosted on http://mydomain.com/beta for more than a year, eventually

@Turnbaugh106

Posted in: #ModRewrite #Redirects

I had an e-commerce website hosted on mydomain.com/beta for more than a year, eventually I decided to move the website to root 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.

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Turnbaugh106

2 Comments

Sorted by latest first Latest Oldest Best

 

@Kimberly868

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 /

10% popularity Vote Up Vote Down


 

@Shelton105

The rules below will redirect (301, permanent redirect -- will change address in URL bar as well) all incoming requests from www.example.com/beta/ to www.example.com/
# activate rewrite engine
RewriteEngine on
RewriteBase /

# redirect from /beta/ to /
RewriteRule ^beta/(.*)$ www.example.com/ [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/(.*)$ / [L,QSA]

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme