A safe process for bulk changing WordPress URLs
Say you need to swap an old domain for a new one in WordPress, so you run a database-wide search-and-replace. The homepage looks fine. Phew.
Then the embedded images vanish, some settings break, and internal links still point at the old host in places the tool never touched.
Bulk URL changes save time, but the database isn’t a text document. WordPress stores data in different structures, plugins keep their own references, and a URL migration can touch redirects, canonical tags, feeds and caches. A careful process makes the change reversible and testable.
Define exactly what should change
Write down the old and new URL patterns, including protocol, hostname, path and any trailing-slash convention. Are you changing the whole domain, a subdirectory, a media host or a specific content path? Separate the intended replacements from URLs that must remain, such as an external service, staging environment or legacy archive.
Inventory where the old URLs appear: post content, page builder data, media references, menus, widgets, plugin settings, custom fields, theme options, sitemaps and canonical output. A search across the database can help find candidates, but it will not necessarily explain how each value is used.
Check how the site is hosted and whether it uses multisite, a reverse proxy, CDN, caching or a managed migration tool. The right process depends on the setup. Confirm who has authority to change DNS, server configuration and application data before starting.
Protect a recoverable copy
Take a fresh database backup and, if files or configuration are affected, a file backup too. Confirm it completed and that somebody knows how to restore it. I don’t count a backup as a rollback plan until I’ve seen a restore work.
Use a staging or local copy that mirrors production as closely as practical. Remove or protect sensitive data under the organisation’s rules before copying, restrict access and keep staging out of search indexes. The aim is to find problems before customers do.
Record the current site settings, redirect rules and key URLs. Keep an export of the planned replacements and the tool or command options used. Avoid relying on memory if the process needs to be reversed or repeated.
Choose a tool that understands WordPress data
WordPress and plugins can store serialized PHP data. A raw text replacement can change string lengths without updating the stored structure. Use a WordPress-aware search and replace tool, and check its current documentation and compatibility with your version. With WP-CLI or a plugin, confirm the syntax, table scope, dry-run behaviour and backup requirements before you run it.
Do a dry run first if the tool has one, and look at how many records and tables it would change. A surprisingly large count suggests the search is too broad. A zero count suggests the pattern is wrong or the data lives elsewhere. I won’t proceed until the numbers make sense.
Restrict the operation to the intended tables and values. Avoid replacing every occurrence of a hostname if the site contains external links or archived content that should remain untouched. Use a precise old string and test representative matches before changing the full database.
Test the change on staging
After replacement, inspect key routes: homepage, posts, pages, product or service pages, images, downloads, forms, menus and any logged-in workflow. Check both internal links and generated assets. Search the rendered source for old URLs and confirm that remaining occurrences are intentional.
Verify redirects from old URLs to the correct new destinations. A domain migration should route the old page to its equivalent where possible, not send every path to the homepage. Check for chains, loops, mixed content and redirect rules that conflict with application routing.
Review canonical tags, hreflang or language annotations, sitemap output, robots directives and structured data. Confirm that analytics, verification tokens, payment callbacks and integrations still work. If the change affects email addresses or API endpoints, test those separately; a URL replacement can have side effects beyond the public pages.
Plan deployment and rollback
Schedule the change when the team can monitor it. Freeze or coordinate content edits during the migration window so that new content is not missed. Communicate who will run the operation, who will test and who can approve rollback.
After deployment, clear relevant caches using the approved process and check the site from an independent session. Monitor server logs, error reports, Search Console and customer support for broken pages or unexpected redirects. Keep the old domain and redirect rules active for the appropriate transition period, based on the migration plan.
If the change fails, use the documented rollback and investigate the cause before attempting a second bulk operation. Do not patch random strings on production while uncertain which tables or settings were affected. Preserve the evidence that will help diagnose the issue.
Check the lasting signals
Update internal links and site settings to use the new canonical URLs rather than relying on redirects forever. Ensure the sitemap contains the preferred URLs and that key external platforms or feeds have been updated. Keep a list of systems that still reference the old address and assign an owner to complete the work.
Review traffic and indexation after search engines recrawl the site. A temporary fluctuation does not automatically mean the migration failed. Compare the intended URL mapping, crawl results and Search Console reports, and investigate specific patterns rather than reacting to one chart.
Make a bulk change reversible
The safest URL migration is scoped, backed up, tested and monitored. WordPress-aware tools, staging and a redirect map reduce risk, but someone still has to check the real site and know how to undo the change.
Related reading
- A practical plugin maintenance plan for a content site
- A maintenance handover for a WordPress site with custom features
- ACF, forks and plugin trust: lessons from the WordPress dispute
Before you run the replacement, can you say exactly which values will change, how you’d restore the previous state and which key routes you’ll test? If any answer is shaky, pause and sort it out first.