Change Your WordPress Domain Without Breaking Anything
Changing a WordPress domain means rewriting thousands of database rows, including serialized data a raw replace corrupts. The safe way: preview, then undo.
The first time I moved a WordPress site to a new domain, I did the “obvious” thing: a big search-and-replace query straight on the database. Ten minutes later the homepage loaded fine and every Elementor page was a wall of broken boxes. I’d corrupted the serialized data—and spent the evening restoring a backup I was lucky to have. A domain change is one of those jobs where the naive way quietly destroys your site and the right way is a handful of guided clicks. Here’s the right way.
The essentials
- Your domain lives in thousands of database rows, not just the
siteurlandhomeoptions you see in Settings. - Widgets, theme settings and many plugin options are stored as serialized data, which a raw SQL replace corrupts by breaking the stored character lengths; Elementor stores its layouts as JSON with escaped slashes (
https:\/\/), which a plain search doesn’t even find; Divi writes shortcodes into the post content itself. - The Domain Changer module rewrites serialized values in place and recalculates their lengths, and catches
https://,http://, protocol-relative//domainand the JSON-escaped form of each. - It previews, table by table, how many rows mention the old domain, and offers a one-click database backup first.
- If anything looks wrong, one click reverts the change (rows edited since are left as they are)—and it never rewrites the post GUID, exactly as WordPress recommends.
Why won’t a simple search-and-replace work?
Because most domain references aren’t plain text. WordPress stores widgets and many plugin options as serialized data—a PHP format where every value carries its exact character count, like s:24:"https://example.com/page". Change the text and leave the 24, and the value becomes unreadable. Elementor adds another trap: its layouts are JSON with escaped slashes, so a search for https://example.com never finds https:\/\/example.com.
Take the serialized case first. Change example.com to mynewsite.org with a raw SQL query: the text gets longer, but the stored 24 doesn’t move. PHP tries to read 23 characters, lands in the middle of your new URL, and gives up: the value is now unreadable. In practice that means empty widgets and plugin settings reset to nothing. Now the Elementor case: the plain query finds nothing to replace in those escaped values, so the layouts keep loading images and links from the old domain. (Divi is the easy one: it writes shortcodes into the post content itself, where a plain replace works.) Together, these two are the reason domain migrations go wrong, and why you need a tool that understands serialized data and the escaped JSON form instead of treating the database as a text file.
Here’s everywhere your old domain is actually hiding—and what breaks if a reference is left behind:
| Where the domain hides | What’s stored there | If it’s left unchanged |
|---|---|---|
siteurl and home | The two options on Settings → General | Nothing—these are the only rows the Settings screen updates |
| Internal links and images | Your post and page content | Links and media keep pointing at the old domain and 404 |
| Elementor layouts | JSON in post meta, with escaped slashes (https:\/\/) | A plain replace never finds them; images and links stay on the old domain |
| Divi 4 layouts | Shortcodes in the post content | Links and media keep pointing at the old domain |
| Widget and plugin settings | Serialized plugin options and widget data | A raw replace breaks the stored length: empty widgets, settings reset to nothing |
| Protocol-relative URLs | The //domain references themes often use | Assets stay pinned to the old host |
| Post GUID | The guid column on every post | Leave it alone—rewriting it makes feed readers show every post as new |
When would you need to change your domain?
You need to change a WordPress domain whenever the address the site is stored under stops being the address visitors use: going live from a staging URL, rebranding, moving between a subdomain and the root domain, or leaving localhost for a real server. Switching HTTP to HTTPS is a different, lighter job. The trigger is almost always one of these:
- Going live from a staging or development URL to production.
- Rebranding to a new domain name.
- Moving from a subdomain (
blog.example.com) to the root domain, or the reverse. - Migrating from localhost to a real server.
Switching plain HTTP to HTTPS is a related but different job—the HTTPS Redirect module handles that more cleanly than a full domain rewrite. And if you’re changing the domain, remember that old inbound links to the previous domain should get 301 redirects so you don’t lose their SEO.
How do you change a WordPress domain safely, step by step?
To change a WordPress domain safely: point the new domain at your server first, back up the database, enter the new domain in the Domain Changer module of Blaminhor Essentials, preview how many rows each table will change, then apply. The module walks every table, rewrites serialized values without corrupting them, and keeps an undo.
A domain change in one picture: one address out, another in, and every URL in the database moved with it—an illustration, not a screenshot of the module.
Step 0 — Point the new domain at your server
Everything the module does happens inside the database. The new domain still has to resolve to your server before anyone (you included) can load the site on it: add the domain to your hosting account, then create or update its DNS records at your registrar—typically an A record to the server’s IP, or a CNAME. If you’ve never touched a DNS zone, how to edit the DNS zone of a domain walks through it. Do this first and give it time to propagate; step 4 ends with a redirect to the new domain, which only works if the new domain already answers.
Step 1 — Back up first (one click)
Click Create Database Backup: the module writes a full SQL dump of your database, and the archive lands in the same folder as your other backups from the Backup & Restore module. This is your safety net, and it’s strongly recommended—but it’s manual: the change itself runs whether or not you’ve made one.
Step 2 — Enter the new domain
The current domain is detected automatically from your site URL. You type the new one—without http:// or https://, just mynewsite.com. The module handles all three reference forms behind the scenes—https://, http://, and the protocol-relative //mynewsite.com that themes often use—plus the JSON-escaped form of each (https:\/\/) that Elementor and anything saved with wp_json_encode() produce.
Step 3 — Preview the exact changes
Click preview and the module scans every table, reporting how many rows in each one mention the old domain—“142 rows in postmeta,” “38 rows in options,” and so on, with a running total. Nothing is written yet. Read the count as a ceiling: it lists every row containing the text of the old domain, while the change itself rewrites only the rows where a full reference (//old-domain) actually appears, and leaves untouched any value that looks serialized but can’t be parsed (those are counted and logged rather than risked). You still see the full blast radius before you commit, which is exactly the confidence a raw SQL query never gives you.
Step 4 — Apply
One click runs the replacement across the whole database: it rewrites every table, siteurl and home included—post content, meta, widgets, plugin settings—with serialized data handled correctly throughout. Because your admin URL itself just changed, the module then sends you to the dashboard of the new domain. Two things follow from that: the new domain must already resolve to your server (step 0), or that page simply won’t load; and your login cookie belongs to the old domain, so expect to sign in again on the new one.
What if something still looks wrong?
If a WordPress domain change looks wrong afterwards, the Domain Changer can undo it: it keeps a journal of every rewritten row and restores each one to its exact previous value, skipping rows you have edited since. That is a one-level undo for the common “that wasn’t right” case; the database backup from step 1 remains your full rollback.
This is where the module goes beyond “hope your backup works.” After a change, it stores the migration in its history and lights up an “Undo this change” button. Click it and the module restores every rewritten row to its exact previous value—rows you’ve edited since the change are left as they are—and clears the history so it can’t fire twice. It’s a genuine one-level undo, not a manual restore.
So you have two nets, not one: the database backup you create before the change, for a full rollback, and the built-in undo for the common case of “that wasn’t right, put it back.” On a multisite install the backups are even kept per-site, so undoing one site’s move doesn’t touch the others.
Why is the safe way to change a domain also the simple one?
Domain changes have an outsized reputation for pain, and most of it comes from two traps: serialized data and JSON-escaped addresses. Handle them correctly and the job shrinks to its real steps: DNS, backup, preview, confirm, done—with the backup you made behind you and an undo button in front of you.
Once you’re on the new domain, set up 301 redirects from the old URLs: Google’s own site move guide says permanent redirects don’t lose PageRank, warns that rankings may fluctuate while it recrawls, and asks you to submit a Change of Address in Search Console whenever the domain itself changes. And if you haven’t yet, force HTTPS site-wide to finish the move cleanly.
Domain Changer is one of the 26 modules in Blaminhor Essentials—free and open-source on WordPress.org.
– blaminhor
FAQ
Why can't I just change my WordPress domain in Settings?
Because the Settings screen only updates two options (siteurl and home). Your domain is stored in thousands of other rows—post content, page-builder layouts, widget data, plugin options—many of them as serialized data. Those references keep pointing at the old domain, so links, images and layouts break until every occurrence is rewritten.
Should I change the post GUID when I move my domain?
No. A GUID is a permanent unique identifier used by feed readers to tell posts apart, not a live link, and WordPress advises never changing it—rewriting GUIDs can make feed readers show every post as new. Good migration tools skip the GUID column by default; the Domain Changer does exactly that.
Do I also need to change my DNS to point the new domain at my host?
Yes—rewriting the database only fixes what's stored inside WordPress. The new domain still has to resolve to your server, which means updating its DNS records (usually an A record or CNAME) at your registrar and adding the domain to your hosting account. Do that first, or the rewritten site simply won't load.
Do I need to update wp-config.php (WP_HOME and WP_SITEURL)?
Only if those constants are already defined there. If your wp-config.php hard-codes WP_HOME and WP_SITEURL, they override the database and must be edited to the new domain by hand. If they're absent—the common case—the database rewrite is enough and you can leave the file untouched.
Will changing my domain hurt my Google rankings?
There's usually a short dip while Google recrawls and reassigns your authority to the new domain, then rankings recover. You minimise the loss by adding 301 redirects from every old URL to its new equivalent, so link equity follows the content. Skip the redirects and the drop can become lasting.
Do I need to submit a change of address in Google Search Console?
When you move to a genuinely new domain, yes—Search Console's "Change of Address" tool tells Google the move is permanent and speeds up the transfer of your rankings. It isn't needed for a staging-to-production switch on the same live domain, but for a real rebrand it's worth the two minutes.
Will my security keys and passkeys still work after changing the domain?
No. A security key or passkey (WebAuthn) is bound to the domain it was registered on, so every one registered on the old domain stops working once the site answers on the new one. Before the change, make sure each account using one has backup codes or another sign-in method; afterwards, register the keys again.
Comments