Moving WordPress to a new domain easily

We recently moved our blog to a new address and the migration went smooth and easy. If you’re looking for a guide to move your WordPress blog to a new domain without annoying your users and search engines, follow the following guide.

  1. Firstly, make sure that your new domain was setup atleast 12-24 hours before, so that it resolves correctly to the required name servers.
  2. Now, copy all files and the database from old to the new domain. You can download a zipped copy of your files from your Hosting Control Panel and the database can be exported via phpMyAdmin.
  3. Now, edit wp-config.php with correct database settings and add the following lines replacing example.com with your new domain.
    define('WP_SITEURL', 'http://www.example.com');
    define('WP_HOME', 'http://www.example.com');
  4. Now, setup your blog the same way as it was on the old domain. Also delete your cache if you were using a caching plugin otherwise it might show the old cached version of the page.
  5. See if your blog works fine. You may need to use the Search and Replace plugin to change the internal links inside the posts such as of images.
  6. Visit all specific pages e.g Homepage, Archives Page, Search Page; etc to check that everything is working as it should.
  7. Now, to redirect all visitors from old domain to the new one, add the following code to your old Domain’s Apache .htaccess file. Don’t forget to replace oldsite and newsitewith your old and new domains respectively.
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^.*oldsite.com$ [NC]
    RewriteRule ^(.*)$ http://newsite.com/$1 [R=301,L]
  8. You can submit a Change of Address request through your Google Webmaster Tools account which will help in updating the Google index faster.

Leave back a message below of how successful your migration went or if you have some doubts.

,

One Response to Moving WordPress to a new domain easily

  1. CouponStatus December 9, 2011 at 12:28 am #

    Yeah, 301 htaccess is right way to cover your visits from old domain to new domain. 🙂

Leave a Reply