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










































March 17th, 2009 23:36
[...] tables and rename them to the proper domain name url. I found this information from this great post here. But the long and short of it is run the following [...]
March 12th, 2009 18:38
Excellent post, thanks for sharing, you’ve just saved me loads of time messing about
March 5th, 2009 08:38
[...] So I searched the web and got this tutorial. [...]
March 3rd, 2009 14:30
This was a great help to me, thanks! I’d just like to add that in WP 2.7 I also had to got to settings>permalinks and hit the save button again to reset those (I’m using ‘pretty’ permalinks.
February 25th, 2009 21:57
Great guide here for managing WP sites. Many thanks!
February 24th, 2009 03:41
Great stuff
Clear and easy to follow, just how a help page should be. Bookmarked for future reference.
February 24th, 2009 03:11
Wow, thanks! I was really afraid to do this (without knowing if I was doing it correctly), so I just decided to go for it and copy-paste 1-2-3. It worked! Note: also, I had to go take out the old index placeholder file I had up there at the designated location. Once that was out of the way, it all showed up.
many thanks again – most helpful!
February 22nd, 2009 15:42
Thanks, this helped me a lot. We are currently moving 2 WP-blogs to a new location.
February 19th, 2009 04:53
worked perfectly. one thing to consider is you have to be patient. it took about 15 min for the changes to propogate even after i cleared my cache. i know it makes no sense but thats the story!
February 11th, 2009 18:56
[...] MySQL Dump Importer If you are moving to a new domain I would also recommend to read this: How to Move WordPress Blog to New Domain or Location My Digital Life [...]
February 10th, 2009 00:48
I think 2 more queries should be added. Many people use additional fields to store queries for thumbnais and there is also info about attachents.
UPDATE wp_postmeta SET meta_value = replace(meta_value, ‘http://www.old-domain.com’, ‘http://www.new-domain.com’);
UPDATE wp_postmeta SET meta_value = replace(meta_value, ‘/home/old-domain/public_html’, ‘/home/new-domain/public_html’);
* This last one may depend on the host home directory and structure.
Long life wordpress!
Cheers, Alex from spain
February 8th, 2009 08:06
[...] Quelle: My Digital Life: How to Move WordPress Blog to New Domain. [...]
February 7th, 2009 08:44
Any one knows, what happens when the destiny domain is a IDN domain (forofundacionserranosuñer.es). I am having big problems and maybe this is why?
Thanks,
February 6th, 2009 21:31
hey,
You have said that “Note that this guide is not about how to move WordPress blog from one server or host to another new hosting service.” But if I want to do this how it is possible. If you have any solution please reply.
BR
moin
January 28th, 2009 16:19
[...] Kudos for this tip. This entry was written by Konstantinos Koukopoulos, posted on January 28, 2009 at 8:19 am, filed under memo and tagged domain, moving, mysql, sql, wordpress. Bookmark the permalink. Follow any comments here with the RSS feed for this post. Post a comment or leave a trackback: Trackback URL. « Obama is left handed [...]
January 27th, 2009 11:20
Thank you very much. I’ve successfully move 2 blogs by referring to this tutorial. Thanx to the writer of this post.
January 26th, 2009 07:33
Thank you very much, following your directions helped me to make the migration without any trouble at all.
What surprised me most was that all my plugins worked right away as well! I was expecting trouble there, especially with NextGEN Gallery.
January 26th, 2009 03:33
Thanks!
January 24th, 2009 03:01
Hey this has helped me so much! Thanks!
January 24th, 2009 02:28
I tried to enter the code, but kept getting errors. what did i do wrong?
January 18th, 2009 20:04
ERay55 hi! how you doin?
January 16th, 2009 10:18
[...] di server yang lama. 3. Karena pindah nama domain maka jalankan perintah mysql berikut (dapet dari sini) [...]
January 16th, 2009 10:00
[...] di server yang lama. 3. Karena pindah nama domain maka jalankan perintah mysql berikut (dapet dari sini) [...]
January 11th, 2009 02:08
[...] (Fore future reference, if I had been interested in moving the blog to a new domain name entirely, I would also have followed the steps here or here). [...]
January 9th, 2009 07:27
[...] para ajustarlo a la url del sitio nuevo, pero me gaste un par de horas en google para encontrar que esta cosa requiere cambios a nivel de base de datos. Luego, mirando más en detalle, descubrí como wordpress guarda los datos, francamente llega a dar [...]