8 September, 2013 — Life —

301 Redirect to a New Domain

Every once in a while you might want to move your blog from one domain to another. This can get very messy if you don’t set-up a 301 redirect properly. By setting up a 301 redirect you keep all the SEO value and your readers are automatically sent to the page they are looking for, only on your new domain.

For example, if you go to http://oldsomain.com/page1 it will automatically send the reader to http://newdomain.com/page1.

Whats the code?

To get this to work simply go to your web hosting FTP or file manager and find the .htaccess file. Edit that file and replace its contents with the following:

# BEGIN WordPress   
RewriteEngine On 
RewriteCond %{HTTP_HOST} ^www.oldsite.com RewriteRule (.*) 
http://www.newsite.com/$1 [R=301,L] 
# END WordPress

Make sure your replace oldsite.com with your old domain name. And newsite.com to your new domain. Be sure not to edit any of the other code as this will affect the way the htaccess file will work.

Once you have done this, upload the .htaccess file to your web host and remove all old WordPress file and your done.
Just make sure you check that everything is working ok.