While migrating your WordPress site or syncing the production database with staging you need to change the domain URL from the database. Instead of crawling within the WP database, I will show you how to change WP domain URL through
wp-cli which is a more effective way with a simple command.
- WordPress site
To change the domain URL through
wp-cli run the following command:
wp search-replace https://old-url.com https://new-url.com --all-tables;
The command will search for the
old-url through the all database tables and replace it with the
new-url domain. To see the changes immediately flush the WP cache with:
wp cache flush;
Now open your browser and navigate to your new domain url.
Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.