Changing the domain of your WordPress install

If you manage a WordPress install, at one point or another you may need to change the domain WordPress is installed on. This can be a huge ordeal as WordPress does not have a function to update all links, references, and sources in use by WordPress. Changing the site link in the Settings will only update the backend for WordPress, leaving your site broken. Here is a better way to change the domain of your WordPress install.

Note that this tutorial assumes you have already moved the WordPress install or changed the domain via your control panel (if applicable). It is advisable to only run these commands once you have moved the WordPress install to it's new location or you have changed the domain in your control panel. There is no need to try and change any settings before hand, only the move is necessary. A backup is highly recommended in addition to this tutorial being performed by a qualified system administrator. If you do not know what you are doing, unrecoverable data loss is highly likely!

1.) Login to phpMyadmin or by using the MySQL cli

2.) Select the database

3.) Change the siteurl setting used by WordPress by running the 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';

4.) Update all guid references to the new site by running the SQL command: 

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


5.) Update all post_content settings by running the SQL command: 

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

Remember to replace OLD-domain.com with the previous domain your site was installed in, take special note of the www, if your site did not use www before, be sure to remove it. Also ensure NEW-domain.com is also replaced with the new domain you plan on using.

If the update was successful, you will receive a message informing you that at least one row has been updated. If you receive a message informing you zero rows were updated, please ensure you are using the proper prefix for your tables (not all installs use "wp_"), and that you are using the proper old domain. When in doubt, contact Mean Servers for assistance in migrating your site, we will provide a reasonable quote!

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

WordPress Plugins: Your Best Friend and Worst Enemy

One of the most frequent complaints we get is that someones website is slow or that the server...

Setup Your Own Private VPN with PPTP

PPTP VPN IntroductionTired of being geo blocked and not being able to watch your favorite TV...

Protect DirectAdmin from Brute Force Attacks

A common method of gaining access over a server is to use a technique called a brute force...

Changing Your Server's Time Zone

Changing the time zone that your server is set to is relatively simple and straight forward. In...

Synchronizing Your Server's Clock

Synchronizing your server's clock is not very difficult as there is a program that can be ran by...