Sometimes it is needed to update the domain URLs for your site. The most normal use case is when you transition a site from being in development to production.
Before following this guide, make sure you do a database export in case you run a wrong command.
We do supply commands for doing this with WP-CLI, but that might be too technical for some. So we will instead take a look at a plugin called Better Search Replace which should be easier to operate. Under we will go through everything to get it up and running.
Time needed: 5 minutes
Step-by-step guide on how to use Better Search Replace:
- Install Better Search Replace
Navigate to the plugins section of your wp-admin. Search for Better Search Replace in the right field. Click install and activate for the first plugin.
- Navigate to plugin
In wp-admin, navigate to Tools > Better Search Replace.
- Enter URLs
In the two first fields you will see what URL to search for and which URL you want to replace it with. So enter your current domain URL in the first field and the domain URL you want to replace it with in the second.
- Select database tables
To change all instances of the domain URL in your database simply select all tables. You can do that by clicking the tables field and enter CMD + A for Mac or CTRL + A for Windows.
- Disable dry-run
Disable the “Run as dry run” option. As dry-running will only simulate the search/replace and not actually do the search-replace.
- Run Search/Replace
Lastly click the “Run Search/Replace” button and you are done!
And as always, should you have any additional questions please don’t hesitate to contact our support chat at servebolt.com!