When Would You Need To Replace URLs
There are quite a few occasions that you would need to replace the old urls in a site with new ones. Here are few that come to mind:
- If you have migrated the site to a new domain
- If you had a site on a staging or temporary site and want to take it live
- If you installed an SSL certificate and have mixed content errors
- If you imported a child theme that contained demo links
I’m going to show you how easy it is to replace the URLs in this tutorial.
Install The Plugin Of Your Choice
There are several plugins that will replace URLs for in your website for free in the WordPress repository. I have tested them all, but not in any methodical or thorough way. It seems there are some instances where one works but not the other, and this can depend what you are trying to do. Here are the plugins I have found that are useful for this:
I tend to always use Better Search Replace, but I don’t think there is a right or wrong. The process is going to be very similar. All of the plugins add this setting to the Tools menu in your Dashboard. Most of the settings interfaces are very similar.
I had to choose one for the tutorial, so I’m going with the one I have used the most and has the most installs, which is Better Search Replace.
Replace The URLs
Now let’s get started replacing the URLs in your WordPress website. To begin, go to the plugin settings located at Tools>Better Search Replace.
In the field that says “Search for” add the url that needs to be replaced.
In the field called “Replace with” add the url
In the “Select tables” area, click to select one of the items and click Control + A on your keyboard to select all of them. They will become highlighted as selected.
If your url happens to be case-sensitive, then check that, but that’s probably rare.
The plugin has the “Run as dry run?” selected by default. This is because this entire action of replacing URLs could break the site if it is not done carefully. Once you are certain the Search for and Replace with urls are definitely correct, you can uncheck this option and proceed.
And now for the big moment. Click the “Run Search/Replace” button to begin the replacement of the URLS in the site.
Once this is completed, the plugin has finished it’s job, so you can deactivate and delete it.