301 Redirect WordPress to New Addon Domain

Posted on January 25, 2015 in WordPress Category

You finally decided that is time to get a new name for your company or website and got a new domain where you want to move your whole WordPress site and do a permanent 301 redirect from old domain to the new one, keeping the same links for each article, but there is a problem with your redirection because you are on a shared hosting and the new domain added in cPanel is an addon domain.

Don't panic. In this simple tutorial I will explain you how to 301 Redirect WordPress using .htaccess, without hurting your page rank in Google Search.

Infinite Loop Redirection Problem to Addon Domain

So you moved everything to your new domain and the website is now working normally like the one from the old domain. You tried to do a simple 301 redirect from old domain to the new one. Luckily, redirection only works from article to article, but not working from root to root domain and causing an infinite loop, which is not good.

Chrome Infinite Redirect Loop

This problem appears because your old domain is the primary domain set up with your cPanel on a shared hosting and everything you write inside old domain's .htaccess will affect Addon Domains, causing an infinite looping redirection.

Addon Domains in cPanel

301 Redirect WordPress using .htaccess

To solve this problem, using a FTP program or through the cPanel's File Mananger, go to your old domain's root and search for .htaccess. You should find it there, because WordPress creates it with some rules. Delete everything inside it and copy the code below.

If you don't have the file there, using your favorite editor, create a plain text file, and save it as .htaccess (without any extension and with a dot in the front of the name). Now add the code below to 301 Redirect WordPress with every link, including home page.

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.new-domain.com$ [NC]
RewriteRule ^(.*)$ http://www.new-domain.com/$1 [L,R=301]

The 301 redirect rule will run under the condition only if the new domain is different than the old domain. That means it will apply only for the old domain. Code will not trigger again when you are on the new domain, solving the redirect looping.

301 Redirect WordPress htaccess FTP

Now all your articles, pages and even home page will now redirect permanently to the new domain.

Tell Google About the 301 Redirection

To avoid any drops in your ranking make sure to inform Google that you are 301 redirect WordPress site. To do that, access Google Webmaster Tools, select your old domain, find the options button and select Change of Address.

Webmaster Tools - Change of Address

How Long Should I Leave the Redirect On

I recommend you to leave the old domain to redirect to the new one for a long time, for more than 6 months, then you can check your links to see if your page rank is back and are the links are moved. Matt Cutts explains in the video below, how long you should leave the redirects when you change your content to a new domain.

Related Articles
  1. Rafael Alfaro says:

    Thank you! I had the exact same problem. This fixed it like a charm. Thank you very much.

  2. Leaj Inarry says:

    I have been looking for some help as I want to move one domain to another, so far I have found a good tutorial on some website that I’m studying at the moment. I would like to know if I need to also do anything with the .htaccess file?

    • Hello Leaj,

      The website you’ve found is about redirecting WordPress and not moving it. If you already moved your site and you still want to 301 redirect WordPress to keep your rank and visits, or if you didn’t moved it, I can help you with that too.

Hint: Wrap your code syntax (html, css or others) between <pre> and </pre> tags. All comments are moderated.

8 − one =

Subscribe by E-mail

HTML-TUTS is built under the mighty WordPress platform.