This tutorial is deprecated in favour of Single Redirects — Example rules · Cloudflare Rules docs
You should replace all instances of
example.com in the screenshots with your domain.
Step 1, The DNS Record:
The first thing you will need is a DNS record for
@, set to . This can point to any IP address as the redirection page rule will execute first. I would recommend pointing it 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:
* means it will forward all pages and the
$1 will keep the path, i.e. if you typed in
example.com/page1, you would be redirected to
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.
Note: If you have HSTS enabled
If your domain is on the HSTS Preload List, a requirement of this is that your domain redirects
https://example.com before redirecting to
www. This can be solved by setting the match URL to
https://example.com/* and ensuring that Always Use HTTPS is enabled. This means the redirects will be:
http://example.com -> https://example.com -> https://www.example.com
http://example.com -> https://www.example.com
and therefore satisfy the requirements for your domain to be preloaded.
Thanks for the report of this in this thread.
Introduction to redirecting with page rules video
Tutorial Reference: CT-27
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