Redirecting One Domain to Another

This tutorial covers redirecting one domain to another. For this, we will be redirecting domainA.com to domainB.com.


The following settings need to be configured under the domain you are redirecting from, in this example, this is domainA.com

Step 1, The DNS Record:
The first thing you will need is a DNS record for @, www and any other subdomains you want to redirect, set to :orange:. This can point to any IP address as the redirection page rule will execute first. I would recommend pointing them to 192.0.2.1 , a dummy IP.


Step 2, The Page Rule:
The second step is the page rule that will perform the redirect. You should add one like this:

This page rule will redirect as per the following examples:

domainA.com > https://domainB.com
www.domainA.com > https://domainB.com
domainA.com/page > https://domainB.com/page
www.domainA.com/page > https://domainB.com/page

Should the domain you are redirecting to be served on www, you can add www to the URL at the bottom of the page rule.

Note about redirect types: This tutorial shows a 302 Temporary Redirect, I would recommend starting with this and checking it functions as required. Then if you intend to keep the new location permananely, switch to a 301 Permanent redirect.

Introduction to redirecting with page rules video



Tutorial Reference: CT-29

Reviewed: 08/21

This is a Community Tutorial, most are wiki posts, so can be contributed to by Regulars and MVPs here. If there is a tutorial you would like to see, you can request one here.

If you would like to provide any feedback on this tutorial, please post in the #Meta category, tag your post #TutorialFeedback and let us know the Tutorial Reference above.

Other great resources on this community include the Community Tips . These address best practices when configuring Cloudflare, how to fix issues you may see, and tools to troubleshoot. Also you can view Expert Tips, great posts on the community from people in the know that may help you with your issue.

We encourage users to check out these great resources and the Cloudflare Support Centre before posting


38 Likes