Migrate/move your WordPress blog to a new domain/server

Well since I just finished migrating this blog over to this new domain, I thought I’d just describe how I actually did it. Firstly, login to your existing blog, Goto Settings, Permalinks and activate the default permalink structure. I recommend doing this because I’ve been locked out a dozen times while updating my blog because of a misplaced .htaccess file. If that happens, whenever you try and login to the WordPress dashboard, it fails. Save your custom permalink structure, if any, for use later. Goto Plugins and de-activate all your plugins. Open up the Akismet page and delete all SPAM that you have in queue (to keep out the junk from getting imported to the new server). The next step is to disallow all robots from your new server. For this, create a file robots.txt with the following content :

User-agent: *
Disallow: /

Now, since I changed servers also, I copied over all my WordPress files from my old server to the new location i.e., from www.uthfull.org/blog to rahulsarin.com. This must include all the content that you might have uploaded, your plugins & themes, the .htaccess and the wp-config.php file.

Use whatever database administration tool you like (I used PhpMyAdmin) and export your database in the form of SQL queries (.SQL) and save it to your PC. Now, use a text editor, such as Notepad++ to open the databse and find all instances of your old domain name and replace it with the new domain. For example, what I did was :

Find : http://www.uthfull.org/blog     Replace with : http://www.rahulsarin.com
Find : http://uthfull.org/blog     Replace with : http://www.rahulsarin.com
Find : http://blog.uthfull.org     Replace with : http://www.rahulsarin.com

Now you might ask why one shouldn’t just change the blog URL in the WordPress admin panel. Well, changing there changes your blog URL but it will not fix the links within your posts, the links on your comments, the link in your user profile and trackbacks & pingbacks (remember, if you link a post on your blog within another post, it sends the post a pingback). You can either go over each change one-by-one or just press the Replace-all button like I did!

Save the edited database file. Now, head over to your new server and create a new empty database. Create a new user and grant it all priviledges to operate upon the database. Now, simply use the import feature to import the database you just edited into the empty database. Wait patiently for it to complete the import.

Once you’ve setup your database, its time to head into your WordPress directory and edit the wp-config.php file. Change the database name to the database you have just created. Change the username and password to that of the new user you have created.

Fire up your browser and type in your new blog address. Hit enter. If you did everything right, then your blog will appear as it normally would on your previous domain. Open up the WordPress dashboard. Re-activate the plugins you had disabled in the first step. If you have any problems with any of the plugins, I recommend deleting all the plugins and simply installing them all over again. I ran into a few errors and they were sorted out this way. Now, head over to Settings, Permalinks and change the permalink structure to your custom structure, if any. Enable your themes, check your blog settings once again and make sure you give your blog a thorough run.

Remove the robots.txt file that you had created to let the spiders come rolling in!!

The final step is to head over to your previous domain. Open up the .htaccess file and type in the following :

Redirect 301 /blog/ http://www.rahulsarin.com/

Change the above according to your own domains. This will help set up a permanent redirect which will point your readers and the search engines automatically to the new domain. It will even work for all pages and posts. So, no readers lost and you get to keep that SEO juice!!

That’s it! Your blog should be up and running on the new domain with all the hits from your previous domain being automatically redirected to the new address. Hope this article helps. I got help from these websites :

Comments are disabled for this post