If you are using Cloudflare and want to 301 redirect all the traffic to the new domain, follow these steps.
Suppose, your subdomain is app.example.com
and want to redirect this subdomain URL to a new website URL example2.com
.
If you don’t have a subdomain added to your DNS record, add it. If the CNAME record of the subdomain is already exist, you have to modify it to change the target.
app.example.com
), “Target” as new domain URL (https://example2.com
). Keep the TLS auto.Remember, if you have a FREE Cloudflare account, you can set a maximum three page rules.
app.example.com/*
“. By adding *
, you redirect all the traffic coming to this subdomain.https://example2.com
.That’s all.
Following these steps, you don’t need to modify any HTML code to redirect.
Now when you enter the subdomain URL in the browser, it will be redirected to the new website. It may take some time to get the DNS record and page rule to apply.
If you have any difficulties for setting Cloudflare to 301 redirect all traffic from subdomain to new domain URL, let me know in the comment section. I will help you.