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.

MDL blog postings now continue at Tip and Trick, and readers are welcome to join My Digital Life Forums.


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

  1. SEO Rob
    January 11th, 2008 04:48
    1

    What’s wrong with using the builtin Export-Import functions and then just install a plugin to redirect the URLs?

    http://rmarsh.com/2006/09/23/moving-your-blog/

  2. Jon-o Addleman
    January 14th, 2008 04:45
    2

    Thanks so much for this! I can’t believe this info isn’t on http://codex.wordpress.org/Moving_WordPress already! I’ve been suffering through all sorts of 404’s ever since following those instructions!

  3. Technomestique » Blog Archive » Déménager son blog WordPress…
    January 16th, 2008 01:20
    3

    [...] article en anglais chez MyDigitalLife explique également comment déplacer son blog WordPress. C’est une méthode très proche de [...]

  4. Kevin
    January 22nd, 2008 07:24
    4

    THANKS!!! I thought I screwed things up royally by trying to organize my domain (and my life). This saved me.

    Cheers

  5. » Welcome! Here we go! Alex Luft: Just another WordPress weblog
    February 8th, 2008 12:13
    5

    [...] is to follow these instructions. I did. Result? All images became broken after the move. I followed these instructions to fix them in my SQL database. No [...]

  6. » And we're back! TechNest: The TechNest — The personal blog of Alex Luft
    February 9th, 2008 10:14
    6

    [...] is to follow these instructions. I did. Result? All images became broken after the move. I followed these instructions to fix them in my SQL database. No luck. The results from the SQL queries stated that [...]

  7. Rob Schultz
    February 19th, 2008 05:59
    7

    Thank you so much for the above instructions. You just saved me a lot of time! Much appreciated.

  8. Samuel
    February 24th, 2008 00:23
    8

    hey, i followed these instructions, but wordpress now just wont display anything. i get a white page when opening index.php… anyway, i can display single pages with example http://url.com/wordpress/?p=123

    strange is that i won’t find any php errors, httpd errors or anything alike. any suggestions?

    samuel

  9. Steve Leung
    March 9th, 2008 15:54
    9

    These SQL statements made my day a lot easier. Thanks!

  10. The Ud
    March 14th, 2008 13:00
    10

    You rock and fixed my site. Gracias.

  11. Samuel
    March 14th, 2008 15:40
    11

    i disabled all plugins, and the site worked again. maybe this helps. bye

  12. Kevin Inscoe - The Morning Report » Blog Archive » Renaming your Wordpress 2.x blog to another domain name
    March 18th, 2008 00:39
    12

    [...] to mydigitallife for the hints on how to do [...]

  13. Luís Reis
    March 27th, 2008 11:59
    13

    To fix images path after moving wordpress to another domain or directory you need to update wp_postmeta and wp_posts so that every link related to posts link to the new wp_content location. We need to do a find and replace in some tables of the database. Using phpMyAdmin You could use the following SQL code to search and replace de links.

    UPDATE tablename SET tablefield = replace(tablefield,”findstring”,”replacestring”);

    One example would be:

    UPDATE wp_postmeta SET meta_value = replace(meta_value,”http://somedomain.com”,”http://somedomain.com/newdir”);

    UPDATE wp_postmeta SET meta_value = replace(meta_value,”http://somedomain.com”,”http://somedomain.com/newdir”);

    or the other way round depending on your case… (this was mine - changed to account root)

    UPDATE wp_postmeta SET meta_value = replace(meta_value,”http://somedomain.com/newdir”,”http://somedomain.com”);

    Note: You can use similar expressions to change links for “wp_posts” table, in this case the field to change is “guid”.

    Note: In my case I had to Update Permalinks in Wordpress Admin->Options->Permalinks to update global linking.

    IMPORTANT: Before changing any table fields look carefully at the field values of the tables in the database so you can decide what values to change.

    This solved my migration of wordpress because after changing files to the server account root directory everything was pointing to the old URL.

    Hope to help, I know what you guys are going through! I had this problem a few days ago.

    Sorry if my English let You down but I’m just a poor Computer Engeneering Student from Portugal :) Have a nice life! Peace!

  14. Luís Reis
    March 27th, 2008 12:37
    14

    Hey again! Forgot to mention that I also had to change links to images inside post content!
    Like this:

    UPDATE wp_posts SET post_content = replace(post_content,”http://somedomain.com/newdir”,”http://somedomain.com/”);

    The method is always the same, find the old link in the table fields and replace by the new one.

    Bye!:)

  15. soul
    March 31st, 2008 13:53
    15

    this occured to me after moving from one webhost to another. i couldnt login as admin.

    tried alot of the cheap fixes but the cheapest of all worked:

    http://www.village-idiot.org/archives/2007/05/22/wp-emergency-password-recovery/

    be sure to delete emergency.php after yer done!

  16. wassup
    April 1st, 2008 03:21
    16

    Thanks for this article.

  17. G
    April 28th, 2008 01:15
    17

    A really great help after moving my wp-installation. Made my day :) Thanks

  18. Philippine Website Developers
    May 1st, 2008 17:16
    18

    Thanks for sharing how to move WordPress blog to new domain or location.

  19. Changer le nom de domaine d’un blog sous wordpress
    May 5th, 2008 20:26
    19

    [...] 1- Backup des données sur le serveur web 2- Backup de la base de données de l’ancien domaine (design.2803) 3- Création du dossier blogdecodesign.fr sur le serveur et de blogdecodesign.com avec une redirection 301 en htaccess vers le .fr 4- Upload de tout le dossier de l’ancien domaine vers le nouveau dossier (blogdecodesign.fr) 5- Création d’une nouvelle base de données 6- Upload de la base de données téléchargée au point 2 dans la nouvelle base de données 7- Exécution des lignes de commandes suivantes pour mettre à jour la base de données (source my digital life): [...]

  20. housespeed
    May 10th, 2008 05:41
    20

    they had the wild playing still there. work visit little done it. let it go. reminded damage the forests

  21. radyo hosting
    May 16th, 2008 18:08
    21

    thanks for sharing this howto

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



Incoming Search Terms for the Article

move wordpress - migrating wordpress - moving wordpress - moving wordpress blog - wordpress change domain - move wordpress to new server - move wordpress blog - how to move blog to new domain - moving wordpress to a new domain - move wordpress new domain - wordpress move domain - move wordpress to new domain - how to move wordpress - moving wordpress to a new host - import sql to new host using new domain - wordpress blog - inurl: /emergency.php - move wordpress to other server - how to move a WordPress blog - wordpress changing domains - change wordpress domain - how to migrate wordpress - migrate wordpress - migrate wordpress blog - move wordpress domain - wordpress move - migrate wordpress domain - move wordpress database - move wordpress database to new host - moving wordpress to new domain - mozgó xp asztal - wordpress absolute urls wp_posts - moving a wordpress blog - move wordpress install - moving wordpress domain - wordpress move url - move wordpress to another host - \'\'move wordpress blog\'\' - change wordpress site location internal - moving to a new doman guide - moving wordpress installation - move wordpress - wordpress move host - wordpress migrating - moving wordpress image posts - change site url in wordpress 2.5 - how to move wordpress site to new domain - how to migrate wordpress to new domain - moving wordpress to different domain - wordpress move to new domain -