This tutorial is deprecated in favour of Single Redirects — Example rules · Cloudflare Rules docs
Archive
Introduction to redirecting with page rules video
Specific Use Cases
You may find a specific tutorial for your use case here, if not then below is some general information and guidance:
- Redirect example.com to www.example.com
- Redirect www.example.com to example.com
- Redirecting One Domain to Another
- Forward A Subdomain To Discord
DNS Records for Page Rules
From the Cloudflare Help Center:
Remember that any Page Rule subdomains must be resolving to Cloudflare in order to work. Subdomains that don’t exist in DNS or aren’t being directed to Cloudflare won’t have Page Rules applied, so you’ll need an “Orange Clouded” DNS record for the subdomain for the Page Rule to work.
Meaning:
You will need a record in the DNS app of your Cloudflare dashboard for the host you are trying to redirect from, set to .
For example:
If I wanted to redirect all users from redirect.example.com
with a page rule then I would need to add a DNS record for redirect.example.com
and set it to . I would recommend creating an A record for the host, pointing to 192.0.2.1
i.e. this record:
replacing redirect with the subdomain you wish to redirect from.
What is 192.0.2.1?
The basic answer:
192.0.2.1 is an illustrative IP address often used for router setups on local networks etc. it doesn’t ‘go’ anywhere!
The official answer:
192.0.2.1 is in the 192.0.2.0/24 block. 192.0.2.0/24 is assigned as
“TEST-NET-1” for use in documentation and example code. It is often used in conjuction with domain names example.com or example.net in vendor and protocol documentation. Addresses within this block do not legitimately appear on the public Internet and can be used without any coordination with IANA or an Internet registry.
Other Resources
Support article explaining the different variables you can use within your forwarding page rules:
https://support.cloudflare.com/hc/en-us/articles/200172286-How-do-I-perform-URL-forwarding-or-redirects-with-Cloudflare-
Tutorial covering the use of wildcards to match patterns when using page rules:
Deprecated - Using Wildcards in Page Rules
Community Tip on page rule best practices:
Community Tip - Best Practices For Page Rules
Tutorial Reference: CT-26
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