It can be challenging and time-consuming to manually update the URLs in your WordPress website, especially if there are dozens of pages and posts.
Luckily, many plugins allow you to easily update the WordPress website URL.
In this article, you'll learn how to use the Better Search Replace plugin to update your old website domain to a new one.
Let's get started.
What Is Better Search Replace?
Better Search Replace is a WordPress plugin that searches and replaces text strings (e.g., a specific keyword) in the database. One of its powerful features is automatically updating the old site URL to a new one.
While the pro version offers more features, the free version is enough for mass-updating the URLs in the WordPress database.
In this article, I'll mainly focus on replacing the old domain URL with a new one.
Reasons for Changing the WordPress URL
There are many reasons for changing the WordPress URL. For example, when you move the site from localhost to live, you need to update the website URL address.
Another common reason is when you move a site from a temporary or staging domain to a public-facing domain.
While you can update the site address from the WordPress Settings page, doing so doesn't guarantee that all the URLs across the site will update as WordPress uses absolute URLs.
Therefore, you need to ensure that all your site URLs are updated with the correct domain URL, otherwise users may encounter issues like 404 not found.
Steps to Update WordPress Website URLs
Let's go through the steps for updating the URLs in your WordPress site.
Step 1: Install and Activate the Plugin
Login to your WordPress Dashboard (WP Admin) and navigate to the Plugins page.
Search and install the Better Search Replace plugin.
Once installed, activate it.
You can find the plugin settings under the Tools sidebar menu.
Step 2: Search and Replace URLs
In the Search/Replace section, use the Search for text field to find the old domain (for example, "localhost") in the database.
And use the Replace with text field to update the new domain (for example, "mysite").
You can specify which database tables to search using the Select tables text box. Generally, it's recommended to select all the tables when you're updating the website domain URL.
Once you're ready, click on the Run Search/Replace button to perform a search and replace - finding and replacing the old domain address with the new one.
In the Additional Settings section, you can choose various options as mentioned below.
- Case-Insensitive: Performs a case-insensitive search (for example, "MySite" and "mysite" are treated the same).
- Replace GUIDs: Updates the "guid" column contents in the "wp_posts" table. However, the WordPress team warns against changing them (read more here).
- Run as dry run: Performs a search only, allowing you to check the results before applying the changes in the database.
Step 3: Confirm the New URL
After you've changed the URLs in the database, check the front end to confirm if everything works correctly (image URLs, fonts, anchor links, etc.).
Conclusion
I hope this article helped you update the WordPress URLs to use the new domain address.
If you notice any issues or need help updating URLs, feel free to contact me via email at [email protected].
Further Reading
You may also be interested to know how to remove the Category base from the WordPress URL. Read the complete article here.