How to change the domain name of your WordPress site

Want to change your domain name and re brand your business, but worried you might loose data or rankings, or does the process sound too technical and scary?

You will be surprised to know that the process can be completed in as little as 20 minutes if you have a plan and know what you are doing. In this post, I’m going to give you a simple fool proof way to swap your domain.

Before we start with the process, let us see why would any one want to change their domain.

  • Your site has been hit by Google panda and penguin algorithm updates, and you want to start fresh with google but don’t want to discard the content you have developed over the years.
  • You are exploring new business opportunities, but your current domain name which you picked without foresight doesn’t reflect your current company.
  • Copyright issues.
  • You domain has been sandboxed by Google.
  • Your domain has been banned from Adsense.

When you want to switch the domain, first question you need to ask is will the new domain be on the new server or the current one. If it’s going to be on the current server, the process is going to little simple and easy. We will cover both scenarios.

  1. Download your database
  2. Open it in text editor, and replace every occurrence of the old domain name with the new one.
  3. Add your domain name to your hosting account and install wordpress as you normally would.
  4. Now goto your new blogs database via phpmyadmin, and dump delete all tables.
  5. Import the database we saved in step 2 to the new one via phpmyadmin.
  6. If the new site will be on the same host, 
    If its on the same cpanel account, copy you wp-content directory from old domain to the new one. You can do this via cpanel very easily.
    If you are hosting on an new host, read the copy files section in this tutorial
  7. Now you should be able to login to the new domain with the user name and password on the old domain.
  8. Goto permalinks, and update their structure. This will generate the htaccess file, and also if you are using a caching plugin save its settings to trigger new cache build process.
  9. Create a temporary post and see if you are able to upload media.
  10. Check everything is fine on the public front of the site.
  11. Once everything is as expected, backup the current htaccess file on the old host. and create a new one with the following content
    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^YourNewDomain.Com$
    RewriteRule ^(.*)$ http://YourNewDomain/$1 [R=301]

    This applies a permanent redirect at the root of your old site, from now on every request to your old domain will be redirected to the new one.
    Ex: http://OldDomain.com/abc-123.html will be redirected to http://newdomain.com/abc-123.html

  12. Goto your webmaster tools, and inform google about the change.
  13. Finally make a search for your old domain on google and see if everything is redirecting correctly

2 Replies to “How to change the domain name of your WordPress site”

  1. If I’m not mistaken this only works flawlessly if the old and new domain names have the exact same length. If not, and the domain name is in a JSON text field, the field is now corrupted as the stored length of the string doesn’t correspond to the its actual content anymore.

    1. Hi Alex,
      Good point. Most of your content is preserved, problem only occurs in cases where the data is stored as serialised array.

      So you will loose some widget content, theme and plugin settings. If a theme provides import export option, they should save the theme settings before following this guide.

Leave a Reply

Your email address will not be published. Required fields are marked *