Published 10th March 2011
Recently I moved this blog from an old URL to a new URL. Part of the complication of doing this is there are several places in the WordPress database where URL’s are stored. This means that when you move to a new domain the database still has all of the old URL’s which, you will quickly find, causes havoc with your WordPress install.
However all is not lost. By simply running these three queries on your database (using phpMyAdmin or whatever you use to control your database) you can update your database easily to your new domain name.
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'; UPDATE wp_posts SET guid = replace(guid, 'http://www.old-domain.com', 'http://www.new-domain.com'); UPDATE wp_posts SET post_content = replace(post_content, 'http://www.old-domain.com', 'http://www.new-domain.com');
Obviously you need to replace “http://www.old-domain.com” and “http://www.new-domain.com” in the code above with your domain names and you are good to go. For a more comprehensive run down moving WordPress see this article.