Moving your WordPress blog to a different host and address
Here’s a quick tip for those of you who are planning to move your blog to a new Web host, a different address, or a different domain name. Of course, these instructions apply whether you’re using the vanilla WordPress, as well as for Turbocharged users.
Update: Welcome, Blogging Pro readers! I’d love to hear your comments and criticism.
Changing your blog to a new location can be an involved process. You can compare it with actually moving to a new house or office. Fortunately, it’s much faster than that. With these instructions, you can move your blog in a very short amount of time, minimizing the amount of downtime for your readers and search engines. Expect to take at the most one day, and in the best scenarios, one hour or less.
The checklist
Be prepared. Make sure you have the following things down.
One or more of these will change during the migration:
- IP address: the Internet address of your Web host. If your blog is not changing Web servers, in all probability the IP address won’t change either.
- domain name: www.yourblogname.com. Perhaps you’ve purchased a new domain name. Perhaps not. Now would be a good time.
- path: the thing in the URL after the domain name, which could be a simple slash (/), or a sub-site, like /blogs/yourname/). Many blogs start out as sub-sites in an existing Web server, but become sites on their own, with their own domain name.
Take note of them as they are now. Also write down the new items as how they’ll be after the changeover.
Don’t forget the essentials as well:
- If changing Web hosts, the IP address and login information for your new Web host. It may be through FTP or SSH.
- The database administration information for your Web host(s). Whether you use phpMyAdmin, one of the Web hosting control panels, or you wing it the old, command-line, fashioned way, this information is crucial.
Have that? OK, time to start. From this point on, no more modifications to your “old” blog. Accept no more comments or pingbacks, publish no more posts, and upload no more files. This can easily be controlled through your WordPress administration panels.
The domain name preparation
Do this step only if you’re preserving your domain name (www.myblog.com), but your blog is changing its IP address (e.g. new Web hosting company).
To successfully do this, you need to have control of your domain name. How you manage it is really up to your DNS provider (and this would be a great time to point out the advantages of managing your DNS yourself). OK, these are the steps:
- Take note of your TTL (the time-to-live, which is usually set to 3600 seconds or 86400 seconds).
- Decrease the TTL to 5 minutes.
- Now wait. If your TTL was 86400 seconds (1 day), wait one day. Sit around and have a few bottles of champagne. It can’t really hurt if you don’t do it every day (ewww, that reminded me of the weekend — crazy, crazy weekend).
The WordPress setup
Skip this step if you’re not migrating to a new Web host. Use your favorite file transfer client to copy all the WordPress files from the WordPress folder in your current host to its new host/destination folder. All files means everything: your uploads, plugins, anything and everything in the WordPress folder. Make sure you preserve the permissions on the files and folders while you do the move — in effect, if e.g. the uploads folder was writable by the Web server, then the move should also result in an uploads folder writable by the Web server on the destination host. At this point, you may not even have a domain name pointing to the new host, so you may have to use the IP address of the new host, but that’s (still) OK.
The database setup
Still with us? Great.
- Using your favorite database administration tool, create a new, empty database on your target host. If you’re not changing Web hosts, do it anyway on your current Web host.
- Create a new user with a password. Grant that user sufficient privileges to the new database.
Don’t do anything else right now.
The content change
If your domain name and path will remain the same during the migration, skip this step.
Time to reconfigure the actual information in the database, so your entire blog agrees completely as to its new URL. Of course, If I may be so bold to plug one of my creations before you decide to change your content, I’ll recommend WordPress AutoLink. You use it to sweep through all your posts automatically — it replaces all absolute URLs with references to the post slugs. The result? Your posts will not point to the old URLs anymore. It’ll dramatically decrease the chances of broken links in your posts and comments, and it’ll ease the following steps as well. Try it.
Usually, this process is quite involved, because it involves editing the WordPress configuration and all hyperlinks in your posts, comments, plugin configuration and blogroll. But I’ve discovered a sure-fire way to do it:
- Export the database to a file! Using the database administration tool in your old Web host, export the entire database as a series of SQL statements.
- Download it to your machine.
- Open it up in your favorite text editor.
- Now search-and-replace all occurrences of the old Web address with the new one. All of them. You may try your luck and do the replacement in one fell swoop, or you may choose to do it one-by-one to actually inspect what you’re changing.
That should more or less do it. I have successfully winged this using the sed stream editor and a single command line: something like cat blog.sql | sed 's|http://oldaddress/|http://newaddress|g' > newblog.sql — but your mileage may vary, and I’m an evil hardcore UNIX hacker. Most people will be happy to do this with Dreamweaver or something alike.
You may still have to do some adjusting, but that would depend on whether your blog posts made reference to absolute paths (/path/to/some/post/) instead of complete URLs (http://yourblog/path/to/post/). All in all, your goal at this stage is to beat up the URLs in your content into making sense on their new context.
Oh, just to be on the safe side, you should audit the changes using a visual diff tool. Meld is quite good at letting you compare the old and new files visually. It’ll help you spot any breakage preemptively. Now, feed this exported, modified SQL file into your freshly created database.
The domain changeover
There are two types of domain changes:
- From www.oldaddress.com to www.newaddress.com
- The domain remains the same, but the IP address changes
Evidently, if both the domain name and the IP address remain the same, you should skip this step.
If your IP address (e.g. Web hosting) changes
Do the DNS changeover. Essentially, make your DNS records for yourdomain name point to the new host. There will be a short window of time– during that time, many hosts will continue to access the old site.After the TTL (time-to-live, which you already set to be 5 minutes)expires, this will stop and your new site will be live.
After doing the changeover, increase the TTL to something reasonable (yes, 86400 seconds is reasonable). This will prevent a storm of DNS requests in the future.
In the meantime, you may fiddle with your computer to make it temporarily pretend that the new IP address is really hosting your blog. Consult your operating system documentation for that, but I’m willing to bet a hundred bucksthat all you’ll have to do is edit a file named hosts or hosts.txt. Don’t forget to reverse this tweak after your new domain name is live.
If your domain name changes
Just make your brand new domain name point to the IP address of your Web host. That’s it. As long as it wasn’t pointing anywhere else, it should be an instant between the configuration and your live site. If it was pointing somewhere else, you’ll have to wait until the TTL (time-to-live) expires. Again, in the meantime you can use the trick in the above paragraph.
Final steps
All done? DNS working? Good. Now:
- Edit the famed
wp-config.phpfile and input the new database information, much in the same fashion as when you initially set up your first blog. - Enter your blog’s address into your Web browser (I use Firefox).
Your blog should be alive.
The 301 Redirect: an important detail
At this point, I’m going to make a wise suggestion: if you changed the address of your blog (the path and/or domain name), you should really make the old address perform Permanent Redirects from the old address to your new address.
This won’t always be possible, because you may not control the configuration of the Web server in the old location, but it certainly is worthwhile, because search engines and readers will be immediately redirected to your new site. Oh, and remember to make the redirects redirect to the actual pages. For example, if you had a blog post at http://oldaddress.com/archives/my-blog-post/, the redirect should go directly to http://newaddress.com/archives/my-blog-post/. You don’t want to confuse readers by redirecting them into your blog’s homepage.
Tip: this is easily done through Apache .htaccess configuration. Google for those terms and you’ll find plenty of tutorials. Maybe we’ll write one in the future.
You’re done!
That’s it! Don’t forget to re-enable commenting and pingbacks.
On an unrelated note, if you changed your domain name, 99% of the time you may want to test your new mail server and mail configuration. This has really nothing to do with WordPress, but, hey, who wants to lose several days of e-mail after a migration? And don’t forget to check Turbocharged out. It may have all you need for your current and next blogs. Plus, should you need it, there’s always assistance with this process from our expert engineers.
Happy blogging!
April 9th, 2007 at 9:54 am
[...] just published a cool tutorial that will help you move your WordPress blog to a new address, no fuss and no muss. Hope you like [...]
April 9th, 2007 at 11:47 am
[...] Original post by Rudd-O [...]
April 9th, 2007 at 11:57 am
[...] post by Rudd-O [...]
April 9th, 2007 at 5:00 pm
[...] Turbocharged has a great tutorial for those looking to move their blog from one web host to another. Sometimes this can be an easy process, other times, not so easy. I recommend upgrading to the latest version of WordPress, and using their Export and Import tools to move your content, but the Turbocharged tutorial goes through more than just that. Changing your blog to a new location can be an involved process. You can compare it with actually moving to a new house or office. Fortunately, it’s much faster than that. [...]
April 10th, 2007 at 9:47 am
Very helpful guide! I needed this, as I’m in planning mode to move my blog to a new host and domain.
April 10th, 2007 at 9:51 am
You’re most welcome, Ron. If you feel you need help with it, I’m extending an invitation for you to contact our engineers. I’ll probably handle the case myself.
April 10th, 2007 at 5:53 pm
[...] Moving your WordPress blog to a different host and address | Turbocharged (tags: wordpress tutorial) [...]
April 11th, 2007 at 8:49 am
[...] WordPress taşımak hakkında yazılmış güzel bir makale. Link [...]
April 11th, 2007 at 10:31 pm
[...] Turbocharged has written a helpful guide for those trying to move their blog to a new web host. [...]
April 13th, 2007 at 8:17 am
[...] I read very useful information on how to move your wordpress blog to a different host and address by turbochargedcms.com [...]
April 18th, 2007 at 11:32 pm
[...] How to Move Your WordPress Blog To Another Host [...]
May 3rd, 2007 at 12:12 am
I’ve got a question about web traffic following a move… …does traffic get counted as having visited Wordpress or as visiting my domain? Drop me an email if you’ve got the details. Cheers
anders
May 12th, 2007 at 11:29 am
Thanks for the post! Planning to migrate into a different host and a new domain name. That editing the sql file has been very helpful!!!
May 19th, 2007 at 9:44 pm
[...] think i’ll get the 20 year deal from smartyhost so moving is out of the [...]
May 23rd, 2007 at 6:10 am
Hi, and thanks for your post. I have one question, my blogs IP is about to change (domain name stays the same) and when i look in the sql file with a text-editor i see hundreds of links to this (old IP) >> i’m a bit confused cause the way i understand your explanation i don’t need to edit it if only the IP changes.
I hope you understand my question, thanks a lot.
November 28th, 2007 at 2:21 pm
Yeah, this is a very very cool blog.
I just added you to my favorites.
Thanx, Mikey
May 25th, 2008 at 3:02 pm
[...] Moving your WordPress blog to a different host and address [...]
July 16th, 2008 at 2:50 pm
[...] by pengusahaonline on July 16, 2008 Turbocharged has a great tutorial for those looking to move their blog from one web host to another. Sometimes [...]