How to Move WordPress Blog to New Domain or Location
For blogger who self-hosts the WordPress blog publishing system on a web hosting server with own registered domain name, sometimes, you may decide to reorganize the blog link URL to make it tidier or to reflect new focus or theme of the blog. If you decide to change the URL or link location of your WordPress blog due to changing of domain name (such as from http://www.old-domain.com/ to http://www.new-domain.com/) or the blog to another directory location (such as from http://www.domain.com/ to http://www.domain.com/blog/), there are some steps that should be done to ensure the proper migration and no breaking links.
The tricky part when moving WordPress blog to another location is that WordPress is using absolute path in URL link instead of relative path in URL link location when stores some parameters in database. Within blog posts’ contents itself, users may also use the old URLs when creating reference backlinks. All these values in the database will need to be changed when WordPress is moved. The following guide will show you which database fields that has references or values related to blog’s URLs that you want to modify. Note that this guide is not about how to move WordPress blog from one server or host to another new hosting service.
Once the blog has been moved (all files copy over in case of moving location or server or new domain name properly propagated across Internet for new domain name), the first thing to change is to tell WordPress the new blog location (wp-config.php should be no changes, and .htaccess file should be also no changes. If for some reason mod_rewrite rules for friendly URLs no longer works, you can always regenerate the .htaccess file via WP Administration’s Update Permalinks page). This value can be changed via WordPress Options page, but if you no longer able to access to old blog URL, you have to modify the value via MySQL database.
Note: The guide uses SQL statements based on MySQL replace() function to modify the database. To run SQL queries, login to MySQL database that houses WordPress tables via phpMyAdmin or login to the DB server and run MySQL client as root.
To update WordPress options with the new blog location, use the following SQL command:
UPDATE wp_options SET option_value = replace(option_value, 'http://www.old-domain.com', 'http://www.new-domain.com') WHERE option_name = 'home' OR option_name = 'siteurl';
After that you will need to fix URLs of the WordPress posts and pages, which translated from post slug, and stored in database wp_posts table as guid field. The URL values in this field are stored as absolute URLs instead of relative URLs, so it needs to be changed with the following SQL query:
UPDATE wp_posts SET guid = replace(guid, 'http://www.old-domain.com','http://www.new-domain.com');
If you have linked internally within blog posts or pages with absolute URLs, these links will point to wrong locations after you move the blog location. Use the following SQL commands to fix all internal links to own blog in all WordPress posts and pages:
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.old-domain.com', 'http://www.new-domain.com');
Browse through WordPress blog to check if everything is okay. You also need to re-login to WP Administration as authentication cookie has now became invalid due to different domain.
Related Articles
- Using PHP-MySQL Persistent Connections to Run WordPress Blog
- Replace Google Blog Search with Technorati for Incoming Links in Dashboard of WordPress
- WLWManifest Disabler Plugin to Remove XLM Link in WordPress Blog Header
- AdSense and Display Banner Ads Rotation in WordPress Blog or Websites
- How to List and Show WordPress Posts That Comments and Pings Off (Not Allow)
- Moderate WordPress Blog Comments Via Moderator with Desktop Client
- How to Rename or Move Oracle Tablespace Datafile to Another Location
- Google Domain Names Registration and Search for Free Apps for Your Domain
- Integrate and Display Google AdSense for Search and Co-Op Custom Search Engine Results in WordPress Blog Page Template
- How to Delete Existing WordPress Post Revisions Stored/Saved










































September 17th, 2008 05:01
[...] moving wordpress site [...]
September 17th, 2008 00:37
[...] Mover un blog en Wordpress a otro dominio: “How to Move WordPress Blog to New Domain or Location“ [...]
September 16th, 2008 21:24
Just used your tutorial and it worked great! Thank you very much!
September 12th, 2008 04:34
[...] case of need, THIS can really helps ! This entry was written by Christophe, posted on September 11, 2008 at 10:34 [...]
September 10th, 2008 13:48
[...] バイトで必要になったので調べた。How to Move WordPress Blog to New Domain or Location » My Digital Lifeというエントリが参考になる。 [...]
September 9th, 2008 00:23
You just save my life! lol!
Thanks for your article.
It worked great! No fuzz!
August 24th, 2008 07:39
[...] database across, and after a few little changes here and there (wordpress plugins and a few little database changes) all was [...]
August 17th, 2008 10:38
[...] Once you have uploaded the posts to the new blog, you’ll also want to consider running the following 2 queries as suggested here: [...]
August 10th, 2008 05:26
great info
August 6th, 2008 18:00
[...] SQL codes from mydigitallife.info SHARETHIS.addEntry({ title: “How to move WordPress blog from old domain to new domain with 301 [...]
August 3rd, 2008 21:45
YOU TOTALLY SAVE MY LIFE!!!!!!!! THANK YOU SO SO SO VERY MUCH! Yea!
July 30th, 2008 15:56
Gold information.
You saved me hours.
Cheers
July 22nd, 2008 11:08
[...] http://www.mydigitallife.info/2007/10/01/how-to-move-wordpress-blog-to-new-domain-or-location/ [...]
July 14th, 2008 20:18
[...] I’ve posted this comment to the mydigitallife.info [...]
July 14th, 2008 20:04
Hi folks,
I had the same probs, butt I never knew on what it depend’s.
I changed the sites Url in the admin area of my Wordpress-blog, but that was an fault.
So nothing would be shown on the right place.
Therefor I needed to change it back, but there is no way to get in the admin area again logically, after I’ve changed the root Url.
So I opened my mind to get a solution. And just in this Moment it comes over me:
…only go on your hosting surface and start PHPmyADMIN and find the following database entry:
“Your WP-Blog database”–>wp_options–>make this database Entry editable–>now find the row “site_url”–>and change in the “options_value”column the root of your blog–>safe it and it’s done!
greetings, Simon
July 9th, 2008 13:38
yes there are open
http://www.demonoid.com/
July 1st, 2008 14:18
Thanks for that. When I googled for this topic another blog said , to this you have to backup the entire database, create new db and upload again. I was really tensed, but this was actually completed in seconds…..:)
June 26th, 2008 22:20
[...] the first thing to be done was to get hold of all the old posts (though very less in number). Here google served as a saviour and I got hold of a plugin called ‘wp-migrate‘, which let me export all the posts along [...]
June 19th, 2008 03:48
Thanks a lot for this tutorial! I’ve been wanting to do this for months but never dared because I was afraid of losing all my hard work. You really saved my day.
June 16th, 2008 08:30
Thanks so much for this post. It was tremendous help. That was so easy to follow and worked perfect.
June 15th, 2008 05:29
[...] all their sites to the new site. Some of these sites were wordpress powered. Thankfully, I found this article that made the move a [...]
June 14th, 2008 02:09
Thanks for this!
Everything working. Thanks for providing this valuable resource. Was invaluable for helping move our prototype Wordpress installation from my home server to full on hosting!
June 10th, 2008 00:26
I had no problem running the first query – the site found the home page instead of displaying a 404 error.
But whilst the second query executes (I am told 2 rows are affected) and when I click a link in the new domain site the correct url is shown in the address bar, all I get is a 404 Not found message saying the requested URL is not on the server – what does this suggest, have I lost some files?
June 9th, 2008 03:03
I just executed this command through PHPMyAdmin after dealing with 2 days of phantom redirects… turns out all that was wrong is I forgot to change the URL. This solved ALL my problems. You have no idea what a godsend this blog was to me. THANK YOU!
June 2nd, 2008 15:34
hi @ all i need plug in for hosting for wp who can help me