Moving wordpress installation to another domain

When you need to move wordpress to another URL, there are few steps you should do:

Step 1: Force to use new domain.

The easiest way is to put the following lines into your wp-config.php. WordPress will automatically set its internal variables to new domain, that you specify here.

define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');

Step 2: Update all images to new domain.

Since wordpress stores all the pages and posts in a database – you need to run special query. If you are using cPanel – login to your cPanel account, go to phpMyAdmin and select database, that wordpress is using. Select SQL tab and execute the following SQL query (remember to set correct table name if you are using table prefixes and set correct old and new url values).

UPDATE wp_posts SET post_content=(REPLACE (post_content, 'old url','new url'));
UPDATE wp_posts SET post_content=(REPLACE (post_content, 'old url','new url'));
UPDATE wp_posts SET guid=(REPLACE (guid, 'old url','new url'));
UPDATE wp_postmeta SET meta_value=(REPLACE (meta_value, 'old url','new url'));
UPDATE wp_yoast_seo_links SET url=(REPLACE (url, 'old url','new url'));

P.S.: these are basic recommendations and I assume you have a little knowledge about PHP and MySQL. Otherwise please look for a guy who knows that or search through wordpress plugins – there are some, which offer these actions through a friendly user interface.

Do you need help?

No worries, simply ask me to help and do this for you.

Leave a Reply

Your email address will not be published. Required fields are marked *