Sometimes you need to move an entire website to a new domain name. There’s lots of ways to do this, but if you’re not careful you might end up losing or confusing visitors (and google). Here’s a quick tutorial to help you out…
Single Page Redirects
Redirect 301 /page.html http://www.example.com/page.html
The line above in a .htaccess file in the root of your old website will send people visiting a specific page, through to a specific page on the new site. If you’ve got lots of pages though, it’s going to be a real pain to list them all.
Entire Site Redirect
Redirect 301 / http://www.example.com/
This will redirect any traffic to your old site to the root of the new site. However, with htaccess we can do better than that…
Entire Site Redirect (Preserving Directories & Pages)
If you have mod rewrite setup in Apache, the following lines in your htaccess file will make sure people get taken straight through to the correct pages on the new site.
RewriteEngine on RewriteRule (.*) http://www.example.com/$1 [L,R=301]
The last example will make sure that your visitors and search engines can find your new content quickly and easily. Also you may notice the ‘301‘ listed in all of these examples – this lets google and other search engines know that the move is permanent.