Community Tip - Best Practices For Page Rules

Scope
Follow the suggestions in this Community Tip to help understand best practices for working with Cloudflare Page Rules.

Background
Cloudflare Page Rules give you the ability to take various actions based on the page’s URL, such as creating redirects, fine tuning caching behavior, or enabling and disabling services. Note that only one Page Rule takes effect on any given request, page rules are given priority in an order from top to bottom, and once a URL matches a rule, only that rule only will be applied, any subsequent rules that also match the URL pattern will not take effect. As a general rule, order rules from most specific to least specific.

Low On Page Rules WAF

Troubleshooting & Rule-Specific Discussion

  1. Watch Must-Use Page Rules for Everyone

  2. Redirect from www.example.com to example.com
    If the URL matches - www.example.com/*
    CLICK “+ A Setting” and select “Forwarding URL”
    Select Status Code - “301 Permanent Redirect”
    Enter Destination URL - example.com/$1
    CLICK Save and Deploy

  3. Redirect from example.com to www.example.com
    If the URL matches - example.com/*
    CLICK “+ A Setting” and select “Forwarding URL”
    Select Status Code - “302 Temporary Redirect”
    Enter Destination URL - www.example.com/$1
    CLICK Save and Deploy

  4. Direct visitors to a specific page with an easy to remember URL:
    If the URL matches - *www.example.com/cf*
    CLICK “+ A Setting” and select “Forwarding URL”
    Select Status Code - “302 Temporary Redirect”
    Enter Destination URL - www.cloudflare.com/plans/
    CLICK Save and Deploy

Lite Reading
https://support.cloudflare.com/hc/en-us/articles/218411427

Lite Viewing

Background Resources
Help Center
Community Tutorials
YouTube

Research The Issue
Community
Google

Performance Option
Securely optimize your domain with Page Rules. The number of Page Rules is set by plan type and additional Page Rules can be purchased. Learn more about additional Page Rules.

If You Need More Help
This community of other Cloudflare users may be able to assist you, login to Cloudflare and post your question to the Community. When you post on the Community make sure to include as much of this information as possible: the specific error message you are seeing, the URLs this is happening on, screen shot of the error, and the steps to reproduce the error. Please indicate what troubleshooting steps you’ve tried in order to help us help you.

This is a Cloudflare Community Tip, to review other tips, click here.

Çevirmek…traduzir…翻译…traducir…Traduire…Übersetzen…:greyg: Translate this Tip

BPCTPR 101019

1 Like

On the

page, the tutorial video appears to be broken! Just wanted to let you know!

@cloonan @cs-cf @ryan

2 Likes

Also adding to @domjh the second or the third examples are wrong, you should probably remove the https:// and the * to make sure to cover only those specific subdomains/root with and without HTTPS.

2 Likes