How to move a website to a new domain and keep the SEO ranking .htaccess

Moving a website to a new domain

This is based on what I did and what I read. Please consult Google's docs yourself before making changes to your site. Ok, let's begin.

Add both domains to Google Search Console

If you haven't already, add your domains to Google Search Console and verify your ownership of the domain property for both the old domain and the new domain.

Redirect your old pages to your new pages

Redirect your old URLs to your new URLs with 301 redirects. You can do this with a .htaccess file in the root directory of your old site or with PHP. For other file types such as PDFs you can configure your server to use rel="canonical" HTTP headers.

A 301 redirect is a permanent redirect that passes full link equity (ranking) to the redirected page. To redirect a single page, you can write
"Redirect 301 /oldpage/ https://example.com/newpage/" in your .htaccess file.

Redirect 301 /oldpage/ https://example.com/newpage/

Maintain the 301 redirects for at least 180 days or for longer if you still see traffic to your old pages from Google Search after 180 days. After 180 days, Google treats the old site like an unrelated site to the new site if still present and crawlable.

If your site is small or medium sized, Google recommends moving all URLs at the same time. This helps Google detect the site move and update their index faster. If your site is large, you can choose to move one section at a time to more easily and quickly detect and fix problems.

Use rel="canonical" links if you can't use 301 redirects

If you use a CMS or dynamic auto-generated URLs or for another reason can't implement 301 redirects, you can tell Google which version of each page you would prefer shown in search results by adding a canonical link tag to each of your old pages.

The canonical version of a duplicated page gets crawled by Google more often and is more likely to be shown in search results.

Add a rel="canonical" link tag to the <head> of each of your old pages pointing to the new version to tell Google your preferred canonical version.

rel="canonical" HTML link tag syntax

Don't try to set canonical pages using the robots.txt file or using the URL removal tool or using a noindex tag. These are not meant for choosing a canonical page.

Check your robots.txt files

If your old site has a robots.txt file, remove directives so Google can find all redirects to your new domain & update their index. If your new site has a robots.txt file, allow all crawling including images, CSS, JavaScript & other files except URLs you don't want crawled.

Create your new sitemap

Add the new URLs for your pages to the sitemap.xml file for your new domain. Upload it to your new domain's root directory & submit a link to it to Google Search Console through the Sitemaps link under your new domain property to speed up the indexing of your URLs.

I left the old sitemap.xml file on the old domain unchanged because eventhough Google doesn't want non-canonical URLs in sitemaps, they still need to know the associated duplicate for any canonicals. The rel="canonical" link is also a stronger signal than canonicals in sitemaps.

Start a Change of Address request

Open your old domain property on Google Search Console, scroll to settings and select "Change of Address". Click "Learn more" on each section and do some further reading to make sure you have fully prepared for your move (don't just rely on this article).

Within the "Change of Address" section of your old domain property, select your new domain property, press "Validate & Update" and ensure you've done everything Google is expecting.

Google wants you to redirect the old home page to the new home page as well as redirect the other old pages to the other new pages.

When you file a "Change of Address" request with Google Search Console, Google emphasises crawling & indexing the new site over the old site and "forwards various signals" from the old site to the new site and prefers the new site when determining canonical pages.

Once the validation passes for your Change of Address, the Change of Address page will say "This site is currently moving" for 180 days.

After 180 days, Google doesn't see a relationship between the old and new sites and your site move should be complete.

If you change your mind, you can cancel a Change of Address request up to 180 days later. To cancel, remove the 301 redirects from the old site to the new site. Add 301 redirects from the new site to the old site. In the Change of Address tool for the old site click Cancel Move.

The domains during a site move

Google recommends renewing your old domain for at least a year to prevent others from registering your abandoned domain for malicious purposes.

If your new domain was previously owned, make sure there are no outstanding issues from a previous owner. Check the Manual Actions page in Google Search Console and address any problems, then submit a reconsideration request. Check for URL removals with Google's Removals Tool.

Keep the same site architecture and URL structure for best results

When moving a site, Google recommends keeping the same site architecture in the new location to help pass the signals more directly to the new site.

If you combine a site move with a redesign of the site's content and URL structure in the new location, you will probably see some traffic loss as Google might need to relearn and reassess the individual pages.

In summary

Thanks for reading.
Ryan

Published on 9 Jul 2021