How to Properly Change Your Domain Name Without SEO Penalties

You’ve had your domain name for years. It’s indexed by Google and has excellent ranking. But you want to change your domain, so what do you do?

You change it!

When Google introduced their Google Webmaster Tools feature they opened up the windows to their data, allowing you in to see the pages they index from your site, the keywords that your site appears for, and a whole variety of additional information.  These tools not only allow you to see how your site is being accessed, but they allow you to control its appearance in Google’s search results.

Change of Address

An additional feature inside Google Webmaster Tools is their “Change of Address” tool, available on the “Site Configuration” menu.  With this tool you have the ability to change your site to appear as a different domain name in Google’s search results.  Instead of waiting for them to re-index your site and worrying that pages will link to the wrong place – Google will now display your search results with the new domain automatically.

You must verify ownership of both your current domain and the new domain in your Google account, so you’ll want to make sure you add your sites to your Google Account before you begin. Opting to buy an expired domain might seem like an absurb idea to many developers, but a surge in traffic is likely to occur with powerful domains still existing within the web.

Google has additional details here about changing your domain name:
http://www.google.com/support/webmasters/bin/answer.py?answer=83106

301 Redirect – Domain Only

While the Change of Address tool preserves your results in Google and avoids the major headaches involved with changing your domain name, you still want to put 301 redirects in place for all of your pages.  A permanent / 301 redirect is the best way to update search engines with new filenames for existing pages, or update to a new domain name in this case.  It should preserve your rankings for that particular page, and is seen as the safest option for doing so.

In order to achieve this on an Apache web server, you would create/edit a .htaccess file in your main www directory. The .htaccess file is simply a regular text file named .htaccess in the root folder of your website.

If *only* your domain is changing (you’re not changing paths or filenames too) then you can put the following code in your .htaccess file:

<IFModule mod_rewrite.c>
RewriteEngine on
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} XXX\.com
RewriteRule ^(.*) http://www.YYY.com/$1 [L,R=301]
</IfModule>
  • Replace “XXX\.com” with your old domain name.  Be sure to put a “\” before the “.” and no “www.” is needed.
  • Replace “www.YYY.com” with your new domain name.  No “\” is needed on this line, and the “www.” in front or not is up to you.

This type of 301 redirect will take *any* page on domain XXX.com and forward the user to the same location but on www.YYY.com instead. This allows you to easily redirect all of your pages, as long as only the domain is changing.  The rest of the paths and filenames must stay the same.

301 Redirects – When Your Path & Files Change Too

If your paths and filenames are also changing, then creating 1 redirect for each file is the way to go.  You may be able to create something similar to the redirect above to redirect groups of pages, but that level of redirect would be outside the scope of this article.

For single redirects, you can add the redirect line(s) to the bottom of an existing .htaccess file if you have one.  The format would be as follows:

To redirect old.html to new.html:

RedirectPermanent /old.html http://www.your_domain.com/new.html

To redirect subdir/old.html to newdir/new.html:

RedirectPermanent /subdir/old.html http://www.your_domain.com/newdir/new.html

The first portion is the web path to the file starting from the main www directory, the second part is an absolute URL to which you would like the aforementioned file redirected.  Whether it’s just a filename that’s changing or your domain name, this process can redirect your old files to their corresponding new pages and get your visitors and the search engines where they need to be.

If the URL you are redirecting from contains any spaces, enclose it in double-quotes, like this:

RedirectPermanent "/subdir/old url.html" http://www.your_domain.com/newdir/new.html

If you need to redirect a dynamic URL such as:

http://www.your_domain.com/index.php?categoryid=46&pageid=167

..or if your website runs on something other than Apache, then you would want to contact your website host to determine the best solution for the redirect.

Google has an excellent article here about changing your domain name as well as additional tips:
http://www.google.com/support/webmasters/bin/answer.py?answer=83105

While it may be a scary idea for a well indexed website to change its domain name – by combining Google’s Change Of Address tool with 301 redirects you can easily update your site to preserve Google results without any errors or missing pages for your visitors.

Looking for a web host that understands ecommerce and business hosting?
Check us out today!

5 Comments

  1. Perfect precise and to the point. Solve my issue perfectly still i have one question.

    I was using wordpress on a domain name which i had to change due to re branding issues. I noticed that many plugins have serialized data inserted in tables. How can i change that to my new server?

    I am familiar with phpmyadmin but i know you can’t simply write update query for serialized values in tables.

    • That is one of the tougher replaces to do Katie. I often just use phpmyadmin and edit each value I find manually. Not the most efficient, but it usually does the job.

      Another option is to export the data to an sql file, do a find and replace with a text editor, then re-upload that sql file. This is faster, but requires more work up front.

      Hope this helps!

  2. ritwick says:

    Well after reading your post i decided to drop the www from my domain name. As both versions refer to two different sites to search engine spiders it’s better to have one version and then redirect another version to it preferably the non www version. Henceforth i’m starting websites with no www in domain name. Thanks for this nice article.

  3. Danny Alva says:

    Thanks for the great info. I have no just one doubt. Do I still have to copy the website into another folder and make the redirection or just add the new domain to my hosting account?

Leave a Reply to Danny Alva