Moving your WordPress site to a new domain

WordPress uses exact URLs when creating posts and pages, this is tricky when you want to move your site to a new domain name.

For example:

If your old domain was “www.olddomain.com” WordPress would have create all URL’s exact (https://www.oldurl.com/pagename/ or https://www.oldurl.com/wp-content/uploads/image.jpg).

Now if we move the website to “www.newdomain.com” all of the old links and images would be broken. 😟

An easy way to change all of your WordPress URL’s in one go is to run these SQL strings from PHPMyAdmin.

UPDATE wp_options SET option_value = replace(option_value, 'https://www.olddomain.com', 'https://www.newdomain.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'https://www.olddomain.com','https://www.newdomain.com');
UPDATE wp_posts SET post_content = replace(post_content, 'https://www.olddomain.com', 'https://www.newdomain.com');
UPDATE wp_postmeta SET meta_value = replace(meta_value, 'https://www.olddomain.com','https://www.newdomain.com');
← Go home