Change your domain name without losing rankings with Cloudflare

ARTRU
Change your domain name without losing rankings with Cloudflare

When you change the domain name of your website, it's important to implement the correct redirects to ensure that you don't lose your search engine rankings.

Cloudflare is a free tool that can help you do 301 redirects, which are the best type of redirects for domain name changes.

Notes before changing the domain name for the website

Make a backup of your old website. Then it pushes to the new domain name, or localhost to test errors.

Make sure that the old domain name is still valid so that the redirection to the new domain name is not interrupted. Because this process can take a few days or months depending on the number of indexed links of the old web.

You do not need to use hosting for the old domain name. This redirection is done through Cloudflare.

What is 301 redirect?

301 redirects
301 redirects

A 301 redirect is a type of HTTP redirect that indicates that a website's URL has changed permanently.

When Googlebot or other search engines visit a website with a 301 redirect, they notice that the URL has changed and update their index to reflect the new URL.

This ensures that users can still find your website in search results, even if they have saved a link to your old URL.

There are several benefits to using 301 redirects when you change the domain name of your website, including:

  • Preserve your search engine rankings: A 301 redirect will tell Google that you've changed your website's URL and that it should redirect users to the new URL. This will help you maintain your search engine rankings and ensure that users can still find your website.
  • Preserve link quality: When you redirect users from your old URL to the new URL, you are also converting link credits. This means that any links to your old URL will still count for the new URL's ranking.
  • Improved user experience: 301 redirects will ensure that users are redirected to the new URL smoothly and without losing any content. This will help improve the user experience and reduce the risk of them leaving your website.

How to 301 Redirect Using Cloudflare

To perform a 301 redirect using Cloudflare, you need to follow these steps:

Go to your Cloudflare account and click on the domain name you want to redirect.

If you want to use redirects that no need hosting then must add A record to any IP. My example is 1.2.3.4

DNS management Cloudflare
DNS management Cloudflare

Find the section Rules and click Page Rules.

Select Page Rules Cloudflare
Select Page Rules Cloudflare
  • Click the button Create Page Rule.
  • Enter the URL of the old domain name old-domain.com/*
  • Select Forwarding URLs301 - Permanet Redirect.
  • Fill in the new domain URL https://new-domain.com/$1
  • Press Save Page Rule to complete the redirect.
Forwarding URLs 301 Cloudflare
Forwarding URLs 301 Cloudflare

Now check by accessing the old domain name. You will be redirected to the new domain name immediately.

The alternative is to use Redirect Rules

  • Select Custom filter expression
  • Use rule sets Hostname equals "old-domain.com"
  • Or you can fill in the expression (http.host eq "old-domain.com")

Item Then:

  • Type selected Dynamic
  • Fill expression concat("https://new-domain.com", http.request.uri.path)
  • Status code select 301.
  • Check the box Preserve query string so that queries are preserved when redirected.
  • Press Deploy to save.
Redirect Rule 301 Cloudflare
Redirect Rule 301 Cloudflare

Notify Google about changing the new domain name

You need to add the new domain name to the Google Search Console tool.

From the old domain management interface → Select SettingsChange of address.

Select the new domain you need to redirect → Click VALIDATE & UPDATE.

Change of address GSC
Change of address GSC

So it's done. The rest is to wait or you can index manually quickly. It took me 2 hours to redirect and a few posts appeared already.

This site is currently moving GSC
This site is currently moving GSC

In addition to using 301 redirects, you can also notify your users that you are switching to a new domain. You can send notifications via email or on social networks.

Before canceling the old domain name you also need to check if there are any unredirected URLs by typing in the search bar: site:domain.com

COMMENT

Related Articles