
How to Move WordPress to a New Domain?
Moving WordPress to a new domain, whether you're rebranding, switching from a .co to a .com, or promoting a staging site to production under its real name, is a different job from a typical WordPress migration. The files and database can move exactly as they are; what actually needs to change is every reference to the old URL baked into your database, plus DNS, SSL, and the SEO signals pointing search engines and visitors at the domain you're leaving behind.
Skip any one of these pieces and you'll end up with a site that half-works: images that won't load because they're still pointing at the old domain, an admin dashboard that redirects you in circles, or a domain switch that quietly drops your search rankings because Google was never told where the content went. This guide walks through the complete process in order.
Before You Start: Back Up Everything
Don't skip this step, even though it's the same advice for any WordPress change. Take a full backup of both your database and files before touching anything, so you have something to roll back to if a step goes wrong partway through. If you haven't done this before, see our guide on how to create a WordPress backup manually for exact mysqldump and wp db export commands.
Step 1: Preview the New Domain Before Switching DNS
If your new domain isn't pointed at your hosting yet, you can still test everything before making it public by editing your computer's hosts file, which lets your browser resolve the new domain to your server's IP address without affecting anyone else:
# On macOS/Linux, edit /etc/hosts
# On Windows, edit C:\Windows\System32\drivers\etc\hosts
203.0.113.10 newdomain.com
203.0.113.10 www.newdomain.com
Replace 203.0.113.10 with your actual server IP. This lets you complete every step below and fully test the new domain in your own browser, while the rest of the world still sees the old domain until you're ready to flip DNS for real.
Step 2: Replace the Old Domain in Your Database
This is the step most people underestimate. Your site's URL isn't stored in one place; it's saved as the home and siteurl options, and it's also embedded directly inside post content (image URLs, internal links), widget settings, and plugin configuration, some of which is stored as serialized PHP data, a format that breaks if you edit it with a plain find-and-replace.
With WP-CLI (Recommended)
If you have WP-CLI available, search-replace handles serialized data correctly, unlike a manual SQL query or a text editor:
# Always dry-run first to see what would change, without changing anything yet
wp search-replace 'https://olddomain.com' 'https://newdomain.com' --dry-run
# Once the dry run looks correct, run it for real across every table
wp search-replace 'https://olddomain.com' 'https://newdomain.com' --all-tables
Run this from your WordPress root directory, connected via SSH. The --dry-run flag is worth taking seriously here: it prints a summary of exactly how many replacements would happen in each table, so you can catch a typo in the old or new domain before it's applied.
Without WP-CLI (phpMyAdmin)
If your host doesn't offer SSH access, you can update the two core options manually through phpMyAdmin's SQL tab:
UPDATE wp_options
SET option_value = 'https://newdomain.com'
WHERE option_name IN ('siteurl', 'home');
This gets your site loading again under the new domain, but it does not fix URLs saved inside post content, widgets, or serialized plugin settings, since those need the same careful handling wp search-replace provides. If you don't have SSH access at all, the Better Search Replace plugin performs the same serialized-data-safe replacement as WP-CLI, entirely through the dashboard.
Step 3: Regain Access if the URL Change Locks You Out
If updating the database URL happens before your new domain's DNS is fully working, you can get locked out of wp-admin, since WordPress will try to redirect you to a domain that isn't resolving yet. Add this to wp-config.php temporarily to force WordPress to use a specific URL regardless of what's stored in the database:
define( 'WP_HOME', 'https://newdomain.com' );
define( 'WP_SITEURL', 'https://newdomain.com' );
These constants override the database values entirely while they're present. Once the migration is confirmed working and DNS has fully propagated, remove them again so the database values (which you've already corrected in Step 2) take over normally.
Step 4: Point DNS at Your Server
With the site verified and working under the new domain (via your hosts file override or a temporary subdomain), update the new domain's DNS records at your domain registrar:
- A record: point
@(the root domain) at your server's IP address. - CNAME or A record: point
wwwat the same server, or at the root domain, depending on your host's requirements.
DNS changes can take anywhere from a few minutes to 48 hours to propagate fully, since it depends on DNS caching around the internet, not just your registrar. Remove the hosts file entries from Step 1 once you've confirmed the new domain resolves correctly on its own.
Step 5: Install an SSL Certificate for the New Domain
Your existing SSL certificate is issued for the old domain and won't cover the new one. Most hosts provision a free certificate (often via Let's Encrypt) automatically once DNS is pointed correctly, but confirm this explicitly, either in your hosting control panel or by running:
curl -I https://newdomain.com
A working certificate returns a normal HTTP response. A certificate error here means visitors will see a browser security warning, so don't move on to the public redirect step until this is resolved.
Step 6: Redirect the Old Domain to the New One
Once the new domain is fully live, set up a permanent redirect on the old domain so existing links, bookmarks, and search results carry visitors and SEO value over automatically. If the old domain is still pointed at the same server, add this to its .htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^olddomain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.olddomain\.com$
RewriteRule ^(.*)$ https://newdomain.com/$1 [R=301,L]
This preserves the full path, so olddomain.com/blog/post-name/ redirects to newdomain.com/blog/post-name/ rather than dropping everyone at the new domain's homepage. For more detail on redirect types and testing, see our guide on how to redirect a page in WordPress.
If the old domain will eventually be given up or pointed elsewhere, keep this redirect running for as long as possible first, ideally 6-12 months, since search engines and external sites can take a long time to fully update their references to the new domain.
Step 7: Tell Google About the Move
A 301 redirect helps, but explicitly notifying Google speeds up how quickly your rankings transfer:
- In Google Search Console, verify ownership of the new domain (if you haven't already).
- With the old domain's property selected, go to Settings → Change of Address.
- Select the new domain as the destination and confirm.
- Submit an updated XML sitemap for the new domain under Sitemaps.
This tool exists specifically for domain migrations and gives Google an explicit signal, in addition to the 301s, that this is a permanent site-wide move rather than individual page redirects.
Step 8: Update Everything That Still Points to the Old Domain
A handful of integrations live outside your WordPress database entirely and need updating separately:
- Google Analytics / Google Ads — update the site URL in your property settings, and update any Ads campaigns pointing at old domain URLs.
- Social media profiles — update the website link in your bio on every platform you use.
- Email signatures and newsletters — update any links embedded in transactional emails or your newsletter platform's templates.
- Third-party embeds — if other websites embed content from you (widgets, badges), reach out where possible, since a redirect handles the visitor experience but not necessarily the embed itself.
Frequently Asked Questions (FAQ) About Moving WordPress to a New Domain
You'll typically see a temporary dip during the transition, even with a correct 301 redirect and Search Console's Change of Address tool, since search engines need time to re-crawl and re-associate signals with the new domain. A properly executed migration (redirects, sitemap, Change of Address) recovers most or all ranking within a few weeks to a couple of months for most sites.
No, permalinks (the path after the domain, like /blog/post-name/) aren't affected by a domain change as long as your site structure itself isn't changing at the same time. Only the domain portion of the URL changes, which is exactly what Step 2's search-replace handles.
This isn't recommended. Serving identical content on two live domains creates duplicate content that confuses search engines about which URL to rank, even if you're not intentionally duplicating anything. A 301 redirect from old to new is the correct long-term setup, not two live copies.
Keep it valid and renewed for as long as you keep the redirect running, since the redirect itself needs to be served over HTTPS to avoid a browser warning before the redirect can even happen. Letting the old domain's certificate expire while still redirecting from it will show visitors a security error instead of completing the redirect.
Check whether those images are referenced with an absolute URL baked into page builder or block editor content that wasn't covered by --all-tables (rare, but possible with certain custom database tables some plugins create), or whether a caching plugin or CDN is serving a stale, cached version of the page. Clear all caching layers and re-check.
It's a reasonable precaution, since there will be a brief window while DNS propagates where some visitors reach the old server and some reach the new one. For most sites the overlap is seamless as long as both the old and new domain point at the same underlying files and database during the transition, but scheduling the DNS cutover during your lowest-traffic period reduces any risk further.
Conclusion
Moving WordPress to a new domain touches more surfaces than a typical migration: the database URLs, DNS, SSL, redirects, and the search engine signals that determine whether your rankings survive the move intact. Work through it in order, database first (with wp search-replace or Better Search Replace, never a plain find-and-replace, since serialized data will break otherwise), then DNS and SSL, then the permanent redirect and Search Console notification that protect your existing traffic and SEO value during the transition.
Keep the old domain's redirect running well after the move feels complete, since search engines and external sites update their references on their own timeline, not yours.
Here are a few additional resources if you want to go deeper:
- WP-CLI Command Reference: wp search-replace — the full reference for the command used in Step 2.
- Google Search Console Help: Change of Address — the official guide for the tool used in Step 7.
- Better Search Replace on WordPress.org — the plugin alternative for sites without SSH/WP-CLI access.


