
Photo by The Consumerist
Well, I did it, and it wasn’t too bad. (Except for this - see update below.) I moved my blog from www.patbdoyle.com to www.patdoyle.com (without the “b”).
The hardest part was upgrading to the latest version of WordPress - I hadn’t done that in a while. Somehow I lost all my categories, but that’s ok. I had lost them a while ago when I tried upgrading before. I’ll just put them back later.
I moved from DreamHost to Hostgator too. Hostgator has Cpanel, which Dreamhost does not have. If they both would have had Cpanel, it would have been even easier.
So here is what I did to move the blog.
- I copied all the files in my root directory (all the files under patbdoyle.com) to my hard drive, using FTP.
- I backed up my WordPress database to my hard drive using the “export” function in phpMyAdmin on Dreamhost. This is where Cpanel would have been easier - you can just go to “Backups” and do a database backup in Cpanel.
There are a lot of settings in phpMyAdmin that I did not know what to do with. So I just followed the instructions in the WordPress documentation: http://codex.wordpress.org/ Backing_Up_Your_Database. That worked just fine.
- The database backup was in zipped format, so I unzipped it on my hard drive.
- I opened the database file with Notepad++, my favorite text editor. You could use plain Notepad too. I did a search and replace, changing “patbdoyle” to “patdoyle”. This changed all the URLS from patbdoyle.com to patdoyle.com.
- Now here is where I did something weird. Because I used phpMyAdmin to backup the database, I should have used phpAdmin on the new domain, to restore the database (using the “import” function). Instead, I tried using the “Backups” option in Cpanel, where you can restore a database.
This did not go very smoothly due to the differing formats. Lesson learned - do the restore the same way as the backup. If you can go from Cpanel to Cpanel, this is easy. If not, then go from phpMyAdmin to phpMyAdmin. If you do use Cpanel, make sure you zip the file up again first. Otherwise the restore won’t work.
- Now go to the files you have downloaded using FTP, and edit the wp-config.php file. (I used Notepad++ again. Or you can use Notepad.) You want the DB_NAME in the wp-config.php file to match the database name that you created. Hostgator puts your username as a prefix on the database name, so I had to add the prefix to the wp-config.php file.
You will also need to look at DB_USER and DB_PASSWORD in this file. These need to match the database user and password that you are going to create in the next step. If your host uses a prefix, then put it there.
Also, look at the DB_HOST. Most hosts just use ‘localhost’ as the hostname, so that is what I had to put here. Dreamhost uses something else, like ‘mysql.patbdoyle.com’. If both hosts use ‘localhost’, you will not have to change this.
- Now, in Cpanel on the new domain, go to “MySQL Databases”. You will see there is already a database there, because we already imported/restored it in a previous step. But we still have to add a user. Make sure the username and password match what is in the wp-config.php file. Then, after you add the user, you have to add the user to the database (on this same screen, just scroll down a little). Check the box for ALL privileges.
- Ok, we are done with the database, but now we still have to move all the other files to the new domain. These are the files you copied from the old domain to your hard drive using FTP. Now we will use FTP again to copy these files to the new domain. Note: For Hostgator, you put all these files in the public_html folder. Make sure you copy the version of wp-config.php that you modified with the correct database information.
- Ok, you are done! If you did everything correctly, you should be able to log in to your new wordpress blog using the same username and password that you used on the old domain.
I did have to make a few other tweaks where I had hard-coded the old domain name in some of my theme’s files. I also had to register the new feed with Feedburner and replace the name of the feed on the new blog.
- After that, I upgraded to the latest version of WordPress. I was quite a few versions behind, so this was a lot of work. I am not going to go into this here, since it has nothing to do with transferring your domain. Just a word to the wise - deactivate all your plugins before you start the upgrade process. They are not kidding when they tell you to do this.
Hopefully you will have kept up with the WordPress upgrades all along, so you will not have to do a major upgrade all at once.
- The last thing you will want to do, after checking to make sure your new blog is ok, is to redirect your old blog to your new blog. To do this, open the .htaccess file at your old blog and put the following commands right at the top of the file. (What comes after these commands will not matter, but I would not delete the rest of the stuff, so it will be easier to undo the redirect if you need to - just delete the first few lines to undo it.)
Here are the redirect commands:
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]Replace “newdomain.com” with your new domain name.
Don’t ask me what all this means. I just googled it, and I found this, and it works.
By the way, the only reason this blog transfer was so easy was that earlier that day, I was copying a WordPress blog I had just created, for a different reason. I had to go through all this with that blog, but it was a lot harder because of the trial-and-error I had to do. I hope I have saved you from some of that trial-and-error. Once you have the steps down, it is pretty easy.
These instructions might not make much sense now, but if you are in the middle of it, and looking at the files and your Cpanel, it will make a lot more sense. Also note, if your host does not have Cpanel, that’s ok. Use whatever your host has. The steps will be much the same. I just think Cpanel makes it easier because it is uniform - a lot of hosts use it.
You can use the same steps if you are just moving your blog to a different host, but keeping the same domain name. You can just skip the steps of replacing the old domain name with the new one, and of doing the redirect at the end.
I hope this post is useful to somebody. Some people requested it when I announced that I was going to be moving my blog.
Update: Just when I thought everything went smoothly, I got a rude awakening. My automatic Blog Broadcast emails from Aweber sent out 10 emails at once - for the past 10 posts of my blog. I quickly sent out an apology email, but two people still unsubscribed. I can’t blame them - who would want to get 10 emails in a day from the same blog?
When I redirected the old blog to the new one, the feed also got redirected. Since the Blog Broadcast in Aweber works from the feed, it thought that there were 10 new posts to broadcast. Lesson learned: Turn off your automatic blog broadcasts before you redirect your blog! My apologies again to those who got all those emails
- Pat Doyle
---
Related Articles at Internet Business with Pat Doyle:






