In this article, I will show you an effective way of updating domain name of a WordPress site after changing the domain. We will do it in two ways: i) Manually with SQL commands and ii) Automatically with a Plugin. I do insist on backing up your WordPress site’s database before proceeding with this tutorial.
How to Replace Old URL After Domain Change in WordPress (Step by Step):
Step 0: Before you go ahead with this step by step tutorial make sure that you have a backup of your Database.
Step 1: Login to your cPanel and Click on PHPMyAdmin.
Step 2: Select the database of your website and click on “SQL” tab.
Step 4: Paste the following code into the SQL command box.
Important:
Note 1: Update the wp_ table prefix according to your website’s database table prefix. In my case, it’s “wpdb_“. So, I shall replace “wp_” with “wpdb_“.
Note 2: Replace “OLD_WEBSITEURL.COM” with your old website domain name and “NEW_WEBSITEURL.COM” with your new domain name.
So, for my case the final codes will look like this:
update wpdb_options set option_value = replace(option_value, 'http://OLD_WEBSITEURL.com', 'http://NEW_WEBSITEURL.com');
update wpdb_postmeta set meta_value = replace(meta_value, 'http://OLD_WEBSITEURL.com', 'http://NEW_WEBSITEURL.com');
update wpdb_posts set post_content = replace(post_content, 'http://OLD_WEBSITEURL.com', 'http://NEW_WEBSITEURL.com');
update wpdb_posts set guid = replace(guid, 'http://OLD_WEBSITEURL.com', 'http://NEW_WEBSITEURL.com');
update wpdb_posts set pinged = replace(pinged,'http://OLD_WEBSITEURL.com', 'http://NEW_WEBSITEURL.com');
update wpdb_comments set comment_content = replace(comment_content, 'http://OLD_WEBSITEURL.com', 'http://NEW_WEBSITEURL.com');
Step 5: Press “GO” button and you are done.
Update WordPress site Domain Name Automatically with a Plugin:
For some users working directly with PHPMyAdmin can be a little trickier. No worries, there’s a nice plugin which can help you to update your WordPress website domain name easily (though I will recommend the manual method above).
You can use “Automatic Domain Changer” plugin for this purpose. After installing this plugin you will find the option for changing domain name by navigating to “Tools” >> “Change Domain“.
Please feel free to comment below if you have any concern, issue or suggestion.
Leave a Reply