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.

Share and contribute or get technical support and help at My Digital Life Forums.



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

Pages: [2] 1 » Show All

  1. We’ve Moved… Everything Must Go! : Foo Kabloo!
    July 22nd, 2008 11:08
    38

    [...] http://www.mydigitallife.info/2007/10/01/how-to-move-wordpress-blog-to-new-domain-or-location/ [...]

  2. Designer-WG » Blog Archive »
    July 14th, 2008 20:18
    37

    [...] I’ve posted this comment to the mydigitallife.info [...]

  3. Simon
    July 14th, 2008 20:04
    36

    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

  4. rebel
    July 9th, 2008 13:38
    35

    yes there are open
    http://www.demonoid.com/

  5. Nikhil George
    July 1st, 2008 14:18
    34

    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…..:)

  6. ——Sahil Seth dot com—— » Back again…
    June 26th, 2008 22:20
    33

    [...] 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 [...]

  7. Phil
    June 19th, 2008 03:48
    32

    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.

  8. Rhett Soveran
    June 16th, 2008 08:30
    31

    Thanks so much for this post. It was tremendous help. That was so easy to follow and worked perfect.

  9. scriptygoddess » Blog Archive » Moving a Wordpress Install
    June 15th, 2008 05:29
    30

    [...] all their sites to the new site. Some of these sites were wordpress powered. Thankfully, I found this article that made the move a [...]

  10. Worcester NO2ID
    June 14th, 2008 02:09
    29

    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!

  11. Stuart
    June 10th, 2008 00:26
    28

    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?

  12. Chad McCanna
    June 9th, 2008 03:03
    27

    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!

  13. radyo dinle
    June 2nd, 2008 15:34
    26

    hi @ all i need plug in for hosting for wp who can help me

Pages: [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 without commenting


Custom Search

New Articles

Incoming Search Terms for the Article

move wordpress - moving wordpress - migrating wordpress - wordpress migrate - moving wordpress blog - move wordpress blog - migrate wordpress - wordpress move domain - moving a wordpress blog - migrate wordpress blog - wordpress change domain - move wordpress to new domain - how to move wordpress - move wordpress to another domain - moving wordpress to a new domain - move wordpress to new server - move wordpress domain - moving wordpress to a new server - how to move wordpress blog - moving wordpress to new domain - wordpress move server - move wordpress blog to new domain - wordpress move - move wordpress database - how to migrate wordpress - moving wordpress database - how to move a WordPress blog - moving wordpress domain - change wordpress domain - wordpress move blog - move wordpress site - domain wordpress - moving wordpress site - move wordpress blog to new server - wordpress domain - moving wordpress to another domain - wordpress migrate blog - move wordpress new domain - wordpress migrating - moving wordpress 2.5 - how to move a blog - move wordpress server - inurl: /emergency.php - wordpress moving - migrate wordpress domain - move wordpress new server - how to move blog to new domain - move wordpress installation - wordpress domain name - wordpress changing domains -