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.

164 Responses to “How to Move WordPress Blog to New Domain or Location”

Pages: [7] 6 5 4 3 2 1 » Show All

  1. Phil King
    November 26th, 2009 05:44
    164

    Many thanks for a great article, just what I was looking for. You might like to add a footnote for those who use relative paths in their blogs for internal links to simply search and replace on the relative path in exactly the same manner as your search and replace method for absolute paths.
    Once again many thanks, Phil at KingSolutions

  2. Williecoetzee
    November 25th, 2009 16:21
    163

    Thank you! Thank You!

  3. Machinadei.com » Moving a Wordpress Website
    November 19th, 2009 03:31
    162

    [...] to reflect the test site URL. I did a bunch of searching and found a great post that explains the MySQL commands you need to use to correct the site so it works correctly. This same procedure would work if you were moving from [...]

  4. Tech: Moving Wordpress to a different Domain | Chatter Of The Squirrel
    November 16th, 2009 16:00
    161

    [...] Learnt everything about this here. [...]

  5. zigzagzz
    November 16th, 2009 15:59
    160

    nice article !

  6. Copying a WordPress Blog to a Different Domain | David’s Technical Musings
    November 8th, 2009 10:38
    159

    [...] How to Move WordPress Blog to New Domain or Location SHARETHIS.addEntry({ title: "Copying a WordPress Blog to a Different Domain", url: "http://dpotter.net/Technical/2009/11/copying-a-wordpress-blog-to-a-different-domain/" });   Email this article   Print this article [...]

  7. nathan
    November 5th, 2009 11:24
    158

    There is nothing I could find on the WP codex that describes these completely essential steps of the migration process completely. Also, the MySQL commands is by far the most difficult bit to understand. Awesome stuff and thanks. I followed your steps and it works (and I understand it too).

  8. Joel Lundgren
    November 5th, 2009 05:16
    157

    Thank you..
    Now I can sleep again..

  9. Kelsi Guidry
    November 5th, 2009 01:36
    156

    I just want to say thank you very much for this article and for your time creating these SQL statements.

    Can i say I Love You?!?! haha

    Thanks,
    Kelsi Guidry

  10. revtrev
    November 4th, 2009 00:56
    155

    The only issue I found was that the new site keeps trying to upload media to the old site. Is there an easy way for me to change this? Where would I look?

  11. RevTrev
    October 31st, 2009 08:57
    154

    Thanks so much for the help for me to merge my blogs. You saved me a tonne of headaches.

  12. Markus
    October 29th, 2009 19:25
    153

    It’s it not necessary to do anything in database for migrate the url to another domain.

    There is another way with this simple steps.

    1. change Blog address and Wordpress adresse (Url) in your general settings -> safe changes

    2. go to settings -> permalinks do nothing and save changes

    so the blog urls been updated.

    please give me a response …

    greetz Markus

  13. Sam Diener
    October 26th, 2009 23:01
    152

    Thank you for this advice. It really helped me.

    Sam

  14. nico
    October 17th, 2009 17:41
    151

    Thanks for the tips !

Pages: [7] 6 5 4 3 2 1 » Show All

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe to comments feature has been disabled. To receive notification of latest comments posted, subscribe to My Digital Life Comments RSS feed or register to receive new comments in daily email digest.

New Articles

Incoming Search Terms for the Article

move wordpress blog to new domain - moving wordpress - move wordpress - migrate wordpress to new domain - how to move wordpress - migrating wordpress - move wordpress to another domain - wordpress move domain - wordpress new domain - how to move wordpress blog to another domain - move wordpress blog - move wordpress to new domain - wordpress move blog - Moving WordPress to a New Server - moving wordpress blog to new domain - transfer wordpress to new domain - wordpress move - move wordpress domain - wordpress migrate - change blog domain - how to move a blog to a new domain - how to move wordpress blog to new host - migrate wordpress - migrate wordpress domain - wordpress blog - wordpress migrate to new domain - how to move wordpress to new domain - how to change domain wordpress - linking wordpress to domain - moving wordpress site to new host - moving a wordpress blog to a new domain - moving wordpress change domain - wordpress blog title sql - wordpress domain change - change wordpress domain - migrating wordpress site - migrate wordpress to new server - wordpress sql to move to another url - wordpress change domain - wordpress domain - wordpress relative urls - change domain wordpress - how to move wordpress to a new domain - migrating wordpress to new domain - move wordpress database to new host - moved wordpress can't login - wordpress change domain mysql - easy way to move wordpress from a server to another server - How to transfer a wordpress site to another url - how to change domain in wordpress -