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










































July 8th, 2009 00:56
I just moved 3 of mine using this guide. Made it easy for me. thanks
July 4th, 2009 10:43
Тhank you very much, very useful info.
July 3rd, 2009 13:37
worked perfectly – many thanks !
July 3rd, 2009 10:37
Thank you so much for this! I just had to transfer my blog to a new site and this was very concise and helpful.
June 19th, 2009 03:51
I couldn’t have done it without you!! Worked perfectly and very simple. Thanks.
June 16th, 2009 09:03
after moved my blog in to new host i can’t login my blog ??
Why ??
June 4th, 2009 19:39
Thanks so much for this!
June 4th, 2009 19:21
Discover the beauty of pakistan. Learn the culture, heritage, traditions and landmarks of different parts of Pakistan especially sindh, punjab, balochistan and N.W.F.P and far northern areas.
June 2nd, 2009 21:32
Thanks Great Help
May 27th, 2009 18:08
Just moved my blog to my new domain http://www.incomesinternationl.com.
Worked perfectly.
Thanks, I appreciate your work.
For those that are having trouble, when using phpmyadmin, make sure you click on the SQL tab then copy in the the 3 queries that have been provided here. Make sure you change the vales for the old-domain.com and new-domain.com and that is all that you will need to do.
Andrew Kolyvas
May 24th, 2009 01:20
Thank you. This worked perfectly.
May 20th, 2009 13:49
it works perfectly.Thank you for sharing this great information with us.
May 17th, 2009 04:46
Brilliant – worked perfectly – many thanks !
May 14th, 2009 03:25
You totally saved me I never would have known how to fix it! Thanks so much!
May 14th, 2009 01:33
Awesome info, this saved me some great webmastering time! Thanks!
May 9th, 2009 08:14
Thank you. This worked perfectly. =]
All I did was copy and paste. =]
May 6th, 2009 10:00
Great article. I just moved my WordPress 2.7.1 blog from one domain to another (same server, same MySQL database). A couple lessons learned:
1. It’s REALLY important that you get your quotes ” correct. I cut & pasted the SQL commands and they didn’t work the first time because the single quotes were too fancy – I typed over them and all was good.
2. The odd thing was that the three SQL commands didn’t change a single thing. I believe that the two plugins had already made all the required domain name changes.
3. There is a wee bit more editing that you need to do in the MySQL DB – you can do it via phpmyadmin. The tables _users, _usermetadata, and _options all need to be reviewed and all occurrences of your old_domain need to be replaced with your new_domain.
4. THIS IS THE ONE THAT GOT ME: please be aware that phpmyadmin will only display the first 30 or so columns of data in a given table. The _options table has MANY more columns than 30. If you forget to change ALL of the occurrences of your old_domain, then you may encounter a “You are not authorized to view this page” error when you log into WP after making your changes.
5. Don’t forget to edit your wp-config.php file in order to change the name of the MySQL database tables being used in the $table_prefix variable.
Good luck and make a backup of your database BEFORE you start!
- Dr. Jim Anderson
April 17th, 2009 08:53
[...] This trick came from an excellent post over at My Digital Life [...]
April 14th, 2009 10:40
[...] mysql commands – Move wp and change “home” and [...]
April 4th, 2009 23:48
[...] As I said I typically search for this information whenever I need to move Wordpress sites. I find the SQL queries at: http://www.mydigitallife.info/2007/10/01/how-to-move-wordpress-blog-to-new-domain-or-location/ [...]
March 31st, 2009 21:08
Yeah, I had that problem with my domain too. I bought a new domain name and when i was transfering my blog onto the new domain, all messed up and i lost a lots of my data:(
Anyway i recovered after some time, it was obviously in the beginning.
But i’m sure information you have provided here will be helpful to may others who are looking forward to shift their blog to a new domain name.
March 31st, 2009 20:02
Hello, i have installed wordpress to domain.org, but i need to have domain.com as main domain (domain.org i wolud lik to be parked) of that installation. If ponit name servers (domain.com) to hosting where is wordpress installed would by blog work??
March 23rd, 2009 11:01
[...] I’ve moved domains, the databases needed some work to fix links. I found an article that was of help, but what you basically do [...]
March 20th, 2009 22:48
works perfectly. thanks!
March 20th, 2009 04:53
Hi, folks!
I’m beginning to transfer the content of a free WP.COM blog to a payed domain and hosting service that supports WP but I still can’t do it. ;(
How is the procedure when I need to transfer all content posted on a free WORDPRESS.COM to a payed hosting service with my own domain?
I want to transfer my wordpress.2009-03-19.xml from heliopaz.wordpress.com to heliopaz.com but the wp-admin doesn’t allow me to upload a XML heavier than just 2 MB and my XML has 13.7 MB.
My host provides a great job but the online chat couldn’t help me and I’m waiting so long for the helpdesk response.
Any solution? May I have to ask my host (or even pay a few more bucks) to increase the space from 2 MB to 15 MB on my heliopaz.com wp-admin page?
Or could I use a FTP software to upload my XML file to a specific directory? In this case, where exactly I have to upload this file?
Thanks a lot!
Hélio Sassen Paz
Porto Alegre/RS
Brazil