Always back up your WordPress database and run a dry run before using Better Search Replace to update URLs. That single habit can save you from broken images, failed logins, missing CSS, and the awful moment when every internal link points to the wrong domain. Better Search Replace is one of the safest ways to update URLs in WordPress because it understands serialized data, which a basic SQL search and replace can easily corrupt.
TLDR: Better Search Replace lets you update old WordPress URLs across the database without manually editing tables. For example, if you move from http://oldsite.com to https://newsite.com, the plugin can replace thousands of stored links in posts, menus, widgets, and options. In a small WooCommerce migration with 18,400 database rows checked, a dry run found 2,137 matches before anything was changed. That preview step is the difference between a clean launch and two hours of panic.
Why URL Replacement Matters
WordPress stores URLs in more places than most people expect. Posts are obvious. Images are obvious too. But URLs also hide inside theme settings, plugin options, page builder content, menu items, custom fields, shortcodes, redirects, and serialized arrays.
That is why changing the site address in Settings > General is rarely enough. It updates the main WordPress URL values, but it does not rewrite every link stored in the database. After a migration, you may still see old URLs in image paths, internal links, buttons, embedded files, and CSS references.
The annoying part is that the site might appear fine at first. Then you open a product page and notice mixed content warnings. Or a background image fails. Or your login redirect sends you to staging. Honestly, it feels like WordPress waits until launch day to show you the one URL you missed.
What Better Search Replace Does
Better Search Replace is a WordPress plugin that scans selected database tables for a specific string and replaces it with another. The common use case is changing URL formats, such as:
- http://example.com to https://example.com
- staging.example.com to example.com
- oldbrand.com to newbrand.com
- example.com/site to example.com
The big reason people use this plugin instead of a raw database query is serialized data support. WordPress plugins often store settings as serialized PHP strings. These strings include character counts. If you replace text without updating those counts, the stored data can break.
For example, a page builder layout may store a URL inside a serialized option. A crude SQL command might swap the text but leave the recorded string length unchanged. The result can be a broken layout or missing settings. Better Search Replace handles that detail for you.
Before You Touch Anything: Make a Backup
Do not skip the backup. Not because it sounds professional, but because mistakes happen fast. One wrong character in the search field can damage far more than expected.
Create a fresh backup of both:
- The database, where URLs and settings live
- The files, including uploads, themes, and plugins
If your host offers one-click backups, use that. If not, use a trusted backup plugin or export the database through phpMyAdmin. Make sure the backup is stored somewhere safe, not only inside the same WordPress install you are about to edit.
How to Use Better Search Replace Safely
Install the plugin from the WordPress plugin directory, then go to Tools > Better Search Replace. The screen is simple, but do not rush. A careful setup takes less than a minute.
- Enter the old URL. Use the exact version stored in the database, such as http://staging.example.com.
- Enter the new URL. Use the final version, such as https://example.com.
- Select tables. For most migrations, select all WordPress tables with your site prefix.
- Run as dry run first. Keep the dry run box checked.
- Review the results. Check how many tables and rows would be changed.
- Run the real replacement. Only uncheck dry run after the preview looks right.
The catch is that one extra slash can change the result. Searching for https://example.com/ is not the same as searching for https://example.com. Decide which format you need before running the tool.
Best Search and Replace Patterns
Use precise strings. Avoid replacing broad terms like example or oldsite. That can alter email addresses, text content, tracking codes, or unrelated plugin data.
For a domain migration, this is usually safe:
- Search for: https://oldsite.com
- Replace with: https://newsite.com
If your old site used both HTTP and HTTPS, run two dry runs:
- http://oldsite.com to https://newsite.com
- https://oldsite.com to https://newsite.com
For staging sites, check whether the database uses staging.example.com, www.staging.example.com, or a temporary host URL. Hosting companies often use odd staging domains, and they love making them longer than necessary. Expect to waste time copying a URL that looks like a password.
What Tables Should You Select?
In most cases, select all tables that belong to your WordPress site. These usually begin with wp_, unless your install uses a custom prefix. Common tables include:
- wp_posts for posts, pages, products, revisions, and attachments
- wp_postmeta for custom fields and page builder data
- wp_options for site settings, theme options, and plugin settings
- wp_terms and wp_termmeta for taxonomy data
- wp_usermeta for user-related stored values
If you run a multisite install, be extra careful. Each site can have its own set of tables. A network-wide replace can be useful, but it can also affect sites you did not mean to touch.
After the Replacement: Check the Site
Once the real replacement finishes, clear every cache you use. That includes page cache, object cache, CDN cache, browser cache, and builder cache. Old URLs may appear to remain simply because cached pages are still being served.
Then test the site like a visitor and like an admin:
- Open the homepage in a private browser window.
- Click main menu links and footer links.
- Check images, buttons, forms, and downloads.
- Open several posts, products, or service pages.
- Log in and confirm the dashboard works.
- Use the browser console to check for mixed content errors.
Common Mistakes to Avoid
Skipping the dry run is the big one. The dry run tells you how many rows will change. If you expect 500 matches and it reports 90,000, stop.
Replacing the wrong version of the URL is another common issue. WordPress may store URLs with or without www. It may also store escaped URLs in some plugin data. Search carefully.
Changing GUID values unnecessarily can also cause trouble. For normal site moves, GUID changes are often harmless, but they are not always needed for RSS and content identity. Better Search Replace may touch them if you select the posts table. If your use case is sensitive, review this before running the final pass.
When to Use WP CLI Instead
For large sites, WP CLI can be faster. The command wp search-replace handles serialized data and works well for developers with server access. It is useful when the database is huge, the admin area is slow, or the plugin times out.
Still, Better Search Replace is easier for many site owners. The dry run screen is clear. The table selection is visible. You can see the impact before making changes. For most small and medium WordPress sites, that is enough.
The Safe URL Update Checklist
- Back up the database and files.
- Confirm the exact old and new URLs.
- Install Better Search Replace.
- Select the correct WordPress tables.
- Run a dry run first.
- Check the number of proposed changes.
- Run the real replacement.
- Clear all caches.
- Test pages, images, forms, logins, and checkout.
Better Search Replace is simple, but it is not a toy. Treat it like a database tool, not a casual settings screen. With a backup, an exact search string, and a dry run, you can update WordPress URLs cleanly and avoid the messy cleanup that comes from rushed database edits.