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.


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

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

  1. Casual Commerce » Wordpress Notes — Going live from local development environment
    March 17th, 2009 23:36
    100

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

  2. Webrevolve
    March 12th, 2009 18:38
    99

    Excellent post, thanks for sharing, you’ve just saved me loads of time messing about

  3. Moving to osama-gma.net
    March 5th, 2009 08:38
    98

    [...] So I searched the web and got this tutorial. [...]

  4. Niels
    March 3rd, 2009 14:30
    97

    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.

  5. TV Me
    February 25th, 2009 21:57
    96

    Great guide here for managing WP sites. Many thanks!

  6. Dan
    February 24th, 2009 03:41
    95

    Great stuff :-)

    Clear and easy to follow, just how a help page should be. Bookmarked for future reference.

  7. susan
    February 24th, 2009 03:11
    94

    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!

  8. Jens
    February 22nd, 2009 15:42
    93

    Thanks, this helped me a lot. We are currently moving 2 WP-blogs to a new location.

  9. Dan
    February 19th, 2009 04:53
    92

    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!

  10. How to transfer a big wordpress blog?
    February 11th, 2009 18:56
    91

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

  11. Alejandro Sevilla
    February 10th, 2009 00:48
    90

    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

  12. WordPress Blog zu neuer Domain verschieben | Dirks Blog
    February 8th, 2009 08:06
    89

    [...] Quelle: My Digital Life: How to Move WordPress Blog to New Domain. [...]

  13. alex
    February 7th, 2009 08:44
    88

    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,

  14. moin
    February 6th, 2009 21:31
    87

    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

  15. memo: change wordpress domain name « Konstantinos Koukopoulos
    January 28th, 2009 16:19
    86

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

  16. KamarSutra
    January 27th, 2009 11:20
    85

    Thank you very much. I’ve successfully move 2 blogs by referring to this tutorial. Thanx to the writer of this post.

  17. Bill Hutchison
    January 26th, 2009 07:33
    84

    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.

  18. Jørn
    January 26th, 2009 03:33
    83

    Thanks!

  19. Hayley
    January 24th, 2009 03:01
    82

    Hey this has helped me so much! Thanks!

  20. Blake
    January 24th, 2009 02:28
    81

    I tried to enter the code, but kept getting errors. what did i do wrong?

  21. mike
    January 18th, 2009 20:04
    80

    ERay55 hi! how you doin?

  22. Migrasi Lagi… « —-aulia_ra—–
    January 16th, 2009 10:18
    79

    [...] di server yang lama. 3. Karena pindah nama domain maka jalankan perintah mysql berikut (dapet dari sini) [...]

  23. Migrasi Lagi… | www.aulia-ra.org
    January 16th, 2009 10:00
    78

    [...] di server yang lama. 3. Karena pindah nama domain maka jalankan perintah mysql berikut (dapet dari sini) [...]

  24. Blog upgrade « Critical Exponent
    January 11th, 2009 02:08
    77

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

  25. Problemas de migración | /dev/GON
    January 9th, 2009 07:27
    76

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

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.
Custom Search

New Articles

Incoming Search Terms for the Article

moving wordpress - move wordpress - move wordpress blog to new domain - wordpress change domain - migrate wordpress - wordpress move domain - moving wordpress to a new server - moving a wordpress blog - how to move a wordpress blog - move wordpress blog - migrating wordpress - move wordpress to new host - moving wordpress to a new domain - moving wordpress blog - move wordpress to new domain - wordpress domain - move wordpress installation - moving wordpress to new host - how to move wordpress - how to move a wordpress blog to a new host - moving wordpress to new domain - how to move wordpress blog - wordpress domain change - how to move wordpress blog to another domain - moving a wordpress site - how to move wordpress blog to new host - how to migrate wordpress - move wordpress new domain - move wordpress to another domain - how to migrate wordpress blog - move wordpress domain - Moving wordpress database - wordpress migrate - migrating wordpress to new domain - change wordpress domain - moving a wordpress blog to a new host - moving wordpress to another domain - move wordpress blog to new host - moving wordpress site - link wordpress to domain - how to move wordpress to new domain - migrate wordpress blog - move wordpress - wordpress moving domains - wordpress domain name - wordpress move blog - move wordpress different domain - wordpress new domain - move wordpress to different domain - migrate wp to another domain -