Website Developers.com.au
www.websitedevelopers.com.au
  • Home
  • Website Development

Change your domain name for WordPress Blog

WordPress is the most popular blogging software in the world, but it still has some imperfect features that will get blogger into troubles. For example, the absolute URL in WordPress may bring problems.

Sometimes, WordPress bloggers want to change their blog domain names, they may run into the same problem as I met when I planned to download my whole blog from website to local machine to make big changes on it: when I login into local host "//localhost/WordPress/wp-admin", I was always re-directed to my website "//top5browsers.com /wp-admin". I was crazy when I met this trouble, especially when I was totally a newbie in WordPress. After doing a lot of search and study on Google, I finally found this simple solution.

The root cause for this problem is WordPress is using absolute path in URL links instead of relative path when stores data and parameters in SQL database. When users write posts or generate pages, many operations like uploading pictures, linking to other internal posts or pages, can create a lot of absolute URLs also. All these absolute URLs stored in the database will need to be changed if WordPress blog is changed to another Domain.

To change the database, you will need to use SQL statements based on MySQL replace() function. To run SQL queries, firstly login into MySQL database that houses WordPress tables via phpMyAdmin or login into the database server and run MySQL client as root.

There are two tables that need to be modified. The first one is wp_options that stores option parameters. You can use below SQL command to updated "option_value" field in "wp_options" table:
UPDATE wp_options SET option_value = REPLACE(option_value, 'old-domain', 'new-domain') WHERE option_name='home' OR option_name='siteurl';

The second table is wp_posts that stores WordPress posts and pages. There are two fields inside this table need to be updated: one is "guid" field that is translated from post slug, the other one is "post_content" that may have internal links with absolute URLs. You can use below SQL commands to updated these two fields:

UPDATE wp_posts SET guid = REPLACE(guid, 'old-domain','new-domain');

UPDATE wp_posts SET post_content = REPLACE(post_content, 'old-domain', 'new-domain');

Article by Jeremy Dawes from
Jezweb, Australian Web Designers, Developers and Hosting

About the Author

Jeremy Dawes

http://www.jezweb.com.au

It all began with Jeremy producing websites from from home on weekends. The business continues to grow and refine the excellent quality of service and support provided for business...

  • Disclaimer and Terms & Conditions
  • Contact Us
  • Privacy Policy
  • Reviews & Listing Guidelines
  • List Your Business

Copyright 2011 WebsiteDevelopers.com.au.