How to change your domain name in WordPress without losing your SEO
TL;DR: A domain change keeps your rankings only if search engines can follow every old URL to its new equivalent. The core steps are: back up, copy the site to the new domain, replace the old domain in the database, set up page-by-page permanent 301 redirects at the server level, submit a sitemap for the new site, add and verify both domains in Google Search Console and use the Change of Address tool after the redirects are live. Google's guidance is to keep the redirects for at least 180 days and recommends keeping the old domain registered for at least a year. Expect some fluctuation while Google reprocesses your site. The move is not a quick fix for anything, so do it only for good reasons, such as a rebrand, and never chain a second move straight after the first.
Should you change your domain at all
Good reasons: a rebrand, a legal or trademark issue, moving from a clumsy domain to a better one or consolidating several sites.
Poor reasons: hoping to "reset" a site after a ranking drop, or chasing a keyword-rich domain. A domain change does not escape a quality problem, and it adds risk. If your traffic fell after an update, see how to check whether a Google update hit you first.
Choose the new domain carefully before you start. Check its history, because a previously used domain can carry problems, and see the WHOIS lookup guide for how to inspect registration data. Our post on expired and aged domains for SEO covers the risks.
What is at stake
Search engines treat a domain as the site's identity. When it changes, they have to learn that the old URLs now live at new addresses and transfer the history, links and signals to them. The 301 redirect is how you say that. Missing or wrong redirects mean lost rankings, broken backlinks and 404s.
Google says that, for a move with URL changes, its systems need to see a permanent redirect several times before they record the change, and that crawling is prioritised and limited, so the transfer takes time. Our explanation of 301 versus 302 redirects covers why the permanent type matters.
Before you start: preparation checklist
- Decide the new domain and register it. Point its DNS to your hosting. See how long DNS propagation takes if you are unsure about timing.
- Keep the same URL structure where possible. If
/blog/my-post/becomes/blog/my-post/on the new domain, redirects are simple. Changing the structure at the same time increases risk, so do one thing at a time. - Choose HTTPS on the new domain from the start. See how to force HTTPS.
- Record your current performance. Export Search Console performance data and your top pages, queries and backlinks. You will need a baseline.
- Crawl your old site with a crawler to list every URL, including images, PDFs and attachments, as your redirect map.
- Choose a quiet date. Avoid your peak season or a big campaign.
- Tell stakeholders. Developers, marketers and anyone who manages email, ads and social profiles.
- Check your host's ability to serve both domains, and to apply server-level redirects.
Step 1: back up everything
Take a full backup of files and the database, and keep a copy off the server. See how to back up a WordPress site properly and test the restore. A domain change touches the whole database, so you want a clean way back.
Step 2: copy the site to the new domain
You have two common approaches.
- Move in place. Keep the same hosting account, add the new domain as the primary domain and change the WordPress URLs. This is faster but riskier, because you cannot test before switching.
- Clone first (recommended). Copy the site to the new domain on staging, test thoroughly, then switch DNS and redirects. See our staging guide and migrating without downtime.
If the new domain is on a new host, copy files and database, update wp-config.php with the new database details and import the database.
Block search engines from indexing the staging copy while you test, and remove the block before launch. Forgetting to remove a "discourage search engines" setting is a common mistake.
Step 3: replace the old domain in the database
WordPress stores your full URL in many places. A simple find-and-replace on the database file is unsafe because some values are serialised, which means they record string lengths. Use a tool that handles serialised data.
With WP-CLI (recommended):
# Dry run first: shows what would change
wp search-replace 'https://olddomain.com' 'https://newdomain.com' --skip-columns=guid --dry-run
# Run for real after checking the dry run
wp search-replace 'https://olddomain.com' 'https://newdomain.com' --skip-columns=guid
Run it again for variations such as http://olddomain.com, //olddomain.com and www.olddomain.com. Skipping the guid column is deliberate, since GUIDs are meant to be permanent identifiers.
Without the command line: use a reputable search-and-replace plugin that supports serialised data. Run its dry-run mode first.
Then:
- Check Settings, General and confirm the WordPress Address and Site Address show the new domain.
- Update
WP_HOMEandWP_SITEURLif you have defined them inwp-config.php. - Go to Settings, Permalinks and click Save to refresh rewrite rules.
- Clear all caches: plugin, server and CDN.
- Look for hard-coded old URLs in theme files, widgets, page-builder settings and custom code.
Step 4: set up 301 redirects
This is the most important step. Redirect every old URL to its exact equivalent on the new domain, not just to the home page.
Apache or LiteSpeed (.htaccess on the OLD domain's site):
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$ [NC]
RewriteRule ^(.*)$ https://newdomain.com/$1 [R=301,L]
This sends olddomain.com/any/path/ to newdomain.com/any/path/, which only works when the paths match.
Nginx:
server {
listen 80;
listen 443 ssl;
server_name olddomain.com www.olddomain.com;
# ssl_certificate lines for the old domain go here
return 301 https://newdomain.com$request_uri;
}
Keep a valid SSL certificate on the old domain so that HTTPS requests to old URLs can still be redirected.
If URLs changed: build a mapping file, old URL to new URL, and implement it with a redirect rule list or a redirect plugin. Redirect each page to the closest equivalent page. Redirecting everything to the home page is treated like a soft 404 and wastes the link value.
Best practices:
- Use server-level 301s, not JavaScript or meta refresh redirects.
- Avoid redirect chains. Old URL should go straight to the final URL in one hop.
- Do not redirect to pages that then redirect again.
- Test with
curl -Iand a crawler.
curl -I https://olddomain.com/blog/some-post/
# Expect: HTTP/2 301 and location: https://newdomain.com/blog/some-post/
For general redirect pitfalls, see IP and host canonicalization and fixing too many redirects.
Step 5: update everything that mentions the old domain
Redirects keep old links working, but you should still update the sources.
- Sitemap: generate a fresh XML sitemap on the new domain, with only new URLs. See XML sitemap errors and fixes.
- robots.txt: point the sitemap line to the new address.
- Canonical tags and Open Graph tags: make sure they use the new domain.
- Internal links: the search-replace handles most of them, but check menus and widgets.
- Backlinks: contact the owners of your most valuable links and ask them to update to the new URL. Redirects pass most signals, but direct links are better.
- Google Business Profile, social profiles, marketplaces and directories: update your website address. See the Google Business Profile checklist.
- Email: update email addresses if the domain changes, and set up forwarding from the old domain. See setting up business email on your own domain. Update SPF, DKIM and DMARC for the new domain.
- Analytics and tag managers: update the domain settings and cross-domain tracking.
- Ads and campaigns: update destination URLs.
- Email signatures, printed material and documents.
- Third-party services: payment gateways, APIs and webhooks that whitelist domains.
Step 6: Search Console and the Change of Address tool
- Verify both properties. Add the new domain to Search Console and verify it. Keep the old domain's property verified. See our Search Console setup checklist.
- Submit the new sitemap in the new property.
- Use the Change of Address tool after your redirects are live. Google's documentation says to use the tool after you have moved and redirected your site. You need to be an owner of both properties, with the same Google account, and the tool works at domain level.
- Run it for every variant of the old domain, such as
wwwand non-www, because it does not move subdomains automatically. - Pass the pre-move checks. Fix any critical failures before you continue.
- Do not use it for HTTP to HTTPS changes, changes within the same domain or
wwwconsolidation.
Once the request is accepted, Search Console shows a "move in progress" notice for 180 days. You cannot chain moves: after moving A to B, you cannot immediately move B to C.
The tool helps Google process the move faster, but it does not replace redirects, and it does not remove the old site from the index on its own.
Step 7: monitor the move
For the first weeks, check regularly:
- Search Console, new property: impressions, clicks and indexed pages should grow as the old numbers fall.
- Search Console, old property: indexed pages should fall over time.
- Crawl errors and the Pages report: look for 404s, redirect errors and "Not indexed" pages. See pages not indexed in Search Console.
- Server logs: check that search bots are hitting the redirects and the new URLs.
- Top pages: search for your main keywords and brand name to see which domain appears.
- Analytics: compare traffic with your baseline.
- Backlink tools: check that links are being picked up for the new domain.
- 404s: fix any redirects you missed.
How long to keep the old domain and redirects
- Redirects: Google's Change of Address documentation says to keep them in place for at least 180 days, and longer if Google Search still sends traffic to old URLs. A separate Google comment reported in the press recommended keeping redirects for at least one year, because its systems need to see them several times. Keeping them longer is fine.
- The old domain: keep it registered for at least a year, as recommended in Google's documentation. In practice, many sites keep it indefinitely to protect their brand and avoid someone else registering it. Set up auto-renewal. See what happens when a domain expires.
- Do not point the old domain at something unrelated during that period.
What to expect
- Temporary fluctuation. Rankings and traffic often wobble in the first weeks. Google emphasises the new site for 180 days after you start the migration, according to its documentation.
- Gradual transfer. Old URLs fade from results as new ones replace them.
- Some residual old URLs. Old pages without an equivalent may remain in the index for a while.
- Rebrand effects. Branded searches may take longer to settle if your brand name also changed.
- Not a guarantee. A well-executed move normally recovers, but results vary. If traffic stays down, check for broken redirects, blocked crawling, missed pages or content changes made at the same time.
Common mistakes
- Redirecting everything to the home page.
- Using 302 redirects. Use 301.
- Leaving the site blocked from search engines after launch.
- Forgetting HTTPS on the old domain, which breaks redirects for HTTPS requests.
- Changing URL structure and content during the move.
- Dropping the old domain too early. It is cheap to keep.
- Not verifying both Search Console properties.
- Skipping the
wwwor other variants in the Change of Address tool. - Leaving old URLs in the sitemap.
- Forgetting email authentication records for the new domain.
- Starting a second move before the first has settled.
FAQs
Will changing my domain hurt my SEO?
There is usually some temporary fluctuation. With correct 301 redirects, a Search Console Change of Address and careful monitoring, most sites recover. Mistakes in the redirects are the main cause of lasting loss.
How do I redirect my old domain to the new one?
Add server-level 301 redirects that map each old URL to its equivalent on the new domain, for example with a rewrite rule in .htaccess on Apache or a return 301 in Nginx.
How long should I keep the 301 redirects?
Google says at least 180 days for the Change of Address process and longer if old URLs still get traffic. Another Google comment recommended at least a year. Keeping them longer is fine.
Do I need the Change of Address tool?
It is recommended for a domain move with redirects in place, because it helps Google process the move. It is not for HTTP to HTTPS changes or changes inside the same domain.
How do I change the domain in the WordPress database?
Use a search-and-replace tool that handles serialised data, such as WP-CLI's search-replace command, and run a dry run first.
Should I keep the old domain?
Yes, at least a year, and ideally longer, so you keep the redirects working and prevent anyone else registering it.
Can I move to a new domain and change my URL structure at once?
You can, but it adds risk and makes problems harder to diagnose. If possible, do the domain move first and change the structure later.
How long does it take for Google to process a domain change?
Weeks to months. Google emphasises the new site for 180 days after the move starts, but full settling can take longer.
Conclusion
A domain change is safe when it is boring: a backup, a tested copy, a clean database replace, one-to-one 301 redirects, an updated sitemap, both Search Console properties verified, the Change of Address tool after redirects go live and weeks of monitoring. Keep the redirects for at least 180 days, the old domain for at least a year and resist the urge to change anything else at the same time.
HostCloud can host both domains during the move and help you set up server-level redirects. See the options at https://hostcloud.in.
Sources: