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.
Related Articles
- StatTraq - Wordpress Plugin for Site Statistic and Traffic Counter
- Integrate WordPress including Comments with bbPress Forum using bbSync
- How to Fetch and Show RSS Feeds on WordPress Blog (Atom/RSS Aggregator Plugins) (Excerpt)
- SEO Friendly Rewrite Method to Move Website URL From Subdirectory to Root Parent Folder
- Paginating or Split WordPress Post or Page with NextPage in WordPress Not Working
- Technorati Incoming Links Plugin for WordPress
- How to SEO Optimize WordPress 2.5 Blog Web Page Title Without Optimal Title Plugin (Excerpt)
- PHP Fatal Error on Call to Add_Query_Var in Taxonomy.php After Upgrading to WordPress 2.5 RC2 (Excerpt)
- Download Previous or Old Version of WordPress
- Disable WordPress 2.3 Core and Plugins Update Check and Notification

































January 11th, 2008 04:48
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/
January 14th, 2008 04:45
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!
January 16th, 2008 01:20
[...] article en anglais chez MyDigitalLife explique également comment déplacer son blog WordPress. C’est une méthode très proche de [...]
January 22nd, 2008 07:24
THANKS!!! I thought I screwed things up royally by trying to organize my domain (and my life). This saved me.
Cheers
February 8th, 2008 12:13
[...] 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 [...]
February 9th, 2008 10:14
[...] 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 [...]
February 19th, 2008 05:59
Thank you so much for the above instructions. You just saved me a lot of time! Much appreciated.
February 24th, 2008 00:23
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
March 9th, 2008 15:54
These SQL statements made my day a lot easier. Thanks!
March 14th, 2008 13:00
You rock and fixed my site. Gracias.
March 14th, 2008 15:40
i disabled all plugins, and the site worked again. maybe this helps. bye
March 18th, 2008 00:39
[...] to mydigitallife for the hints on how to do [...]
March 27th, 2008 11:59
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!
March 27th, 2008 12:37
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!:)
March 31st, 2008 13:53
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!
April 1st, 2008 03:21
Thanks for this article.
April 28th, 2008 01:15
A really great help after moving my wp-installation. Made my day
Thanks
May 1st, 2008 17:16
Thanks for sharing how to move WordPress blog to new domain or location.
May 5th, 2008 20:26
[...] 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): [...]
May 10th, 2008 05:41
they had the wild playing still there. work visit little done it. let it go. reminded damage the forests
May 16th, 2008 18:08
thanks for sharing this howto