Having had to go through this process myself, I wanted to write a tutorial on it and share my experience on the subject. Moving your whole WordPress installation to a new domain can be daunting, but by following these steps, it will be a painless process for you and when you type your new domain into a browser and see your site, just as it was on the old domain, you’ll wonder what all the fuss was about.
To move your WordPress installation to a new domain, follow these simple steps:
1. Buy new domain and hosting
First of all, settle on your new domain name, purchase it and arrange for hosting to go with it. Make sure that the DNS is resolving correctly before you switch over. You don’t want to pull your current site down, only to find that the new one isn’t yet resolving.
2. Copy all your files across
Use FTP, cPanel, SSH (or any method you like) to copy all files to your new server. Be sure to get the wp-admin, wp-content and wp-includes folders and all the loose files that reside in the root folder. Be especially sure to get your wp-config.php file (since this may not be in your root folder).
3. Export your database
Your database is where all the meat of your WordPress installation lies, like all your post content, categories, tags and users. Use phpMyAdmin (or other SQL solution) to export your entire database and save the file on your computer.
4. Create a new database
Over on your new hosting, use phpMyAdmin or cPanel to create a new SQL database and user. Assign the user to the database, giving it all privileges.
5. Edit your wp-config.php
Look in wp-config.php in its new location. Check that if there are any references to your old domain (such as define(‘WP_HOME’,’http://example.com’);) that you change them to reflect your new domain. Also be sure to update your SQL database login information and FTP information, if this is included in your wp-config.php.
6. Change domain references in your database
Your database is going to be littered with references to your old domain. Any references to images, posts and your home page will all now be invalid. Use a text editor to find any references to your old domain, and replace them with the new. For example, search for http://www.thewanderingbrit.com (my old domain) and replace it with http://www.doitwithwp.com (my new domain). Be wary of any references you may have used with or without the www and account for it. Save the file.
7. Upload your SQL file
Take the database file and import it into your new database using phpMyAdmin.
8. Make sure everything works
You should have now completed all the steps needed to move your installation to your new domain. Go to your new domain in a browser and make sure that everything’s working as it should.
9. Redirect traffic to your new domain
Now that you have your new site up and running, you want to redirect all traffic from your old site to your new site, so that you don’t lose any traffic and so that any rank with Google is transferred to your new site. There are a few ways to do this – you can either use cPanel on your old site to create a permanent redirect (301), or you can write the 301 redirect into your old .htaccess file manually. To do this, open up .htaccess and remove anything that might be inside and write the following:
This will redirect all traffic to your blog to the same address in your new domain (where http://www.doitwithwp.com is the new domain in the example above). So individual pages will be sent to the same addres on your new domain (i.e. http://www.thewanderingbrit.com/wptouch-is-a-godsend-in-an-increasingly-mobile-world/ will be redirected to http://www.doitwithwp.com/wptouch-is-a-godsend-in-an-increasingly-mobile-world/ – you can check, by trying to visit the old page. You should be sent to the new address.)
You can check that your 301 redirect is working by using a redirect checker tool.
This sequence should see your site moved completely seamlessly to your new domain. You should have all your images and files on your new site, all the posts should be completely intact, with all the links changed to reflect your new site and any visitors (including search engines) to your site should automatically sent to your new site and update their indexes, carrying any rank with it.
As always, if you encounter trouble, leave a comment, or get in touch with me. I’m here to help!