Apache URL Redirects Using .htaccess

I’ve redirected everything from http://eric.willcodeforcoffee.com to http://willcodeforcoffee.com using Apache redirects. It is pretty simple, I just created a .htaccess file in the web root for eric.willcodeforcoffee.com and added this one line:
RedirectMatch permanent ^/$ http://willcodeforcoffee.com/

Now it nicely, and permanently redirects everything from http://eric.willcodeforcoffee.com/.

There is one catch however: what about stuff in sub-folders, like http://eric.willcodeforcoffee.com/files/? The above redirect doesn’t handle that so I also added:
RedirectMatch permanent ^/* http://willcodeforcoffee.com/

It doesn’t redirect to the matching pages, but I don’t really want to do that anyways.

Leave a Reply

Your email address will not be published. Required fields are marked *