Move WordPress to a new domain without losing SEO
· The AYT team · 6 min read

When you migrate a WordPress site to a new domain, your Google rankings survive if you do three things: replace the old address everywhere in the database, 301 redirect every old page to the same page on the new domain, and announce the move in Google Search Console. Skip the redirects and Google treats the new domain as a new site that starts from zero.
Before you start
Get a few things ready before you touch the site:
- the new domain, registered and added to your hosting, with an SSL certificate issued (so the site works on
https://from the start); - a full copy of the site: the files and a database export;
- a list of your important pages, from Google Search Console under Performance → Pages (the ones with the most clicks);
- owner access to the old domain in Search Console; add and verify the new domain now.
If you are changing hosting providers at the same time, do the moves one at a time: first move the site to the new host on the old domain, following the guide to moving a WordPress site. Change the domain only once the site works on the new server. That way you know exactly what caused any problem.
Step 1: put the site on the new domain
If the new domain is on the same hosting, copy the files into its folder and import the database into a new one (or reuse the existing one, if the old domain will no longer serve the site). Enter the database name, user and password in wp-config.php.
Don't change anything on the old domain yet. Until you finish steps 2 and 3, visitors still see the site there.
Step 2: replace the old address in the database
WordPress keeps the site address in two options in the wp_options table, siteurl and home (in wp-admin under Settings → General: "WordPress Address" and "Site Address"). The old address also appears in internal links inside posts, in inserted images, and in theme and plugin settings.
Don't use a plain SQL REPLACE. Many plugins and themes store settings as serialized data, where the length of each string is written next to it. Swap old.com for newdomain.com and the length no longer matches, so those settings are lost without any error.
Use a tool that understands serialization:
- the Better Search Replace plugin, with "Run as dry run" ticked the first time, so you see how many rows change;
- WP-CLI, if you have a command line:
wp search-replace 'https://old.com' 'https://newdomain.com' --dry-run
wp search-replace 'https://old.com' 'https://newdomain.com'
Replace the full address, with https://. Replacing only the domain name can also change email addresses or text that contains the word. If the site ever ran on http:// or with www, run a replacement for those variants too.
Then clear the caches (the cache plugin, Redis, the CDN) and open a few pages on the new domain. Check the menu, images, forms and signing in to wp-admin.
Step 3: a 301 redirect from every old page
Every old address must send a 301 to the same path on the new domain: old.com/services/ to newdomain.com/services/, not to the home page. The redirect keeps the path, so links from other sites land where they should.
On an nginx server, the block for the old domain looks like this:
server {
listen 443 ssl;
server_name old.com www.old.com;
# the old domain's SSL certificate stays valid
return 301 https://newdomain.com$request_uri;
}
On Apache, in the old domain's .htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?old\.com$ [NC]
RewriteRule ^(.*)$ https://newdomain.com/$1 [R=301,L]
The old domain still needs a valid SSL certificate. Otherwise anyone opening https://old.com sees a security warning before they reach the redirect.
Check the redirect with curl -I https://old.com/some-page/: you should see 301 and, under location, the right address on the new domain, in a single hop. A redirect chain (old → www.old → newdomain) works, but it is slower and loses signal. There is more on redirects in the guide to 301 redirects in WordPress.
Step 4: announce the move in Google Search Console
Search Console has a Change of Address tool in the old property's settings. Its conditions, according to Google's documentation:
- the 301 redirects must already work;
- you must be an owner of both properties, from the same Google account;
- the tool works at domain level, not for a subfolder;
- it does not move subdomains (not even
www): run it for each variant you use.
Google recommends keeping the redirects for at least 180 days, longer if search traffic still reaches the old addresses, and keeping the old domain registered for at least a year. In practice, keep them indefinitely: an old domain costs little per year, and links to it stay on other sites for a long time.
After Change of Address, submit the new domain's sitemap (usually /wp-sitemap.xml or the one your SEO plugin generates) in the new property.
Step 5: what else to update
- Your SEO plugin's settings: the canonical address, organisation details, sitemap.
- Google Analytics or another statistics tool, Google Business Profile and your social media profiles.
- Important links on other sites that you or your partners control; the redirect works, but a direct link is better.
- Email addresses. If you use mailboxes on the old domain, don't shut them down abruptly: create them on the new one, forward the mail and tell your customers.
What to expect
Rankings can fluctuate in the first weeks. Google moves the signals gradually, as it revisits the old pages and finds the redirects. Watch the indexing reports and 404 errors in Search Console, on both properties. A new 404 on the new domain usually means an address that the replacement in step 2 missed. For 404 errors in general, see how to fix 404 errors on WordPress pages.
Frequently asked questions
Can I just use a redirect plugin on the old site?
Only if the old site stays installed and working on the old domain. It is simpler and safer to let the web server do the redirect, with one rule for the whole domain.
Do I lose my backlinks?
No, as long as the 301 redirects stay active. The links lead to the old domain, and the redirect passes them on.
On AYT hosting
On AYT's paid plans, moving your sites is free and done within 2 working days, with the site online throughout. The SSL certificate for the new domain (including www) is issued and renewed automatically. The WordPress Toolkit has a database search and replace, so you can do step 2 from the panel without a plugin. The web server is nginx, so .htaccess rules are not read. Add redirects for individual pages from the panel's Redirects page. For the whole old domain, add it as a separate site from Create a New Domain, with "Nothing: an empty site" under Install, and put a single file in its folder, index.php:
<?php
header('Location: https://newdomain.com' . $_SERVER['REQUEST_URI'], true, 301);
The server sends every address that isn't an existing file to index.php, so each old page lands on the same path on the new domain. The old domain's SSL certificate is issued automatically, as long as the domain points to the server.
