Moving to a New Domain? Use Apache to Redirct the Old to the New

Posted January 29th @ 12:34 pm  |  Filed in: Apache    

So you have to move your site to a new domain - it happens. One of my clients just had to go through this because of a legal issue. But never fear - there’s no need to break your existing search engine results, or websites that have linked to your old domain, or folks that have bookmarked you, etc. Put these three lines, and only these three lines, into an .htaccess file on the old site (assuming you’re using Apache as your web server):

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^ http://www.new-domain.com%{REQUEST_URI} [L,R=301]

Of course, replace “www.new-domain.com” with your new domain. That’s it. Every request that goes to the old site will be automatically redirected to the new. In case you’re wondering, the “301″ number sends what’s called a “header message” to the search bots that this is a permanent move, and that they should update their records accordingly. This elegantly avoids any duplicate content issues.

No Comments Yet

You can be the first to comment!

Leave a comment

OpenID Login

Standard Login

Options:

Size

Colors