Changing the domain name of your WordPress website using 301 redirects


First off, I’ve been battling with this for hours and hours and the solution in the end was so simple I was kicking myself. I suddenly thought I’m not the only one who is banging their head on the desk over this one so thought I’d explain my mistakes and hopefully save some of you a heap of time.

Here’s my problem: I have a WordPress website at www.xxx.co.uk and I needed to move it to www.yyy.com.au without impairing my seo rankings. It’s worth pointing out that the site is the same, it’s just the domain name that is changing here.

Sound simple right? Well it is when you understand a few little curve balls.

Here are the steps to take:

1. Make sure you have both the old and the new domains verified in Google webmaster tools.

2. In Google webmaster tools, move the old domain to the new one.

3. Change the domain name to the new one in the settings section of your WordPress blog

4. Use a 301 .htaccess redirect so that any old links that are around will point to your new domain.

It’s point number 4. that I want to go into a bit more depth and explain.

I was searching high and low for the correct method of redirection and finally found it. I can confirm that it works perfectly. All you need to do is create a .htaccess file in the root of the WordPress site with the following code. (note that if you are using permalinks, you may already have one, in which case you just need to edit it)

# BEGIN Redirect Rewrite
 Options +FollowSymLinks RewriteEngine On RewriteBase /
 RewriteCond %{HTTP_HOST} !xxx.com.au$ [NC]
 RewriteRule ^(.*)$ http://www.xxx.com.au/$1 [L,R=301]
# END Redirect Rewrite
# BEGIN WordPress
 RewriteEngine On
 RewriteBase /
 RewriteRule ^index\.php$ - [L]
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule . /index.php [L]
# END WordPress

To explain this further, the “!” before the “xxx.com.au$” means that if the incoming domain is NOT your new one, then rewrite it to the new one and send the user there.

It’s also very important to have these rules BEFORE the WordPress rules, if you don’t then permalinks will not be redirected, only the root domain will be.

That’s it. Leave a comment if you need any additional help.


Leave a comment