Update WordPress Blog Location

On August 15, 2010, in Web, by Bikas

If your Blog is made on WordPress platform and you want to change the location/ URL of the Blog, which may be due to reasons like: your have built the site on your system locally using the localhost in your URL; or your blog is already hosted with different domain name and now you want to host it with some other domain name, this article may be of some use to you fellows. Just follow the few simple steps mentioned below.

  1. First of all logon to your Blog’s database through PhpMyAdmin control.
  2. Then select your Blog’s database. You will find 15-16 tables under it using the prefix “wp_”.
  3. Now you need to pass some queries for some of the tables; to be precise you need to pass some queries for three tables which are mentioned below:

First update wp_options table:

To update WordPress options with the new blog location, first select the wp_options table on the left panel. Then select “SQL” on the right panelA� and pass the below mentioned query in the textbox for the query and click go to pass the query.

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';

your old domain will be http://localhost/your_blog if you have built the site locally on your system.

Second update wp_posts table: This will 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, so we need to change them with the following SQL query:

UPDATE wp_posts SET guid = replace(guid, 'http://www.old-domain.com','http://www.new-domain.com');

Lastly update wp_posts table:
This will fix the URL links which you have used to link posts or pages internally within the posts you have published, which we will change using the following SQL query:

UPDATE wp_posts SET post_content = replace(post_content, 'http://www.old-domain.com', 'http://www.new-domain.com');

Now re-login to your wp-administration to update the cookies and also check your blog and post if they are working properly.

Tagged with: