Recommended Page Rules to Consider

With Cloudflare Page Rules you can improve user experience of your domain with hardened security, and enhanced site performance while increasing reliability and minimizing bandwidth usage for your origin server.  Keep in mind that not all rules will be right for everyone, but these are some of the most popular. You can review step by step instructions for deploying them below.  These same rules can also by reviewed in this video.

  • Always Use HTTPS
  • 301/302 Forwarding URL
  • Security Level & Cache Level
  • Edge Cache TTL, Always Online, & Browser Cache TTL

 

Always Use HTTPS

SSL is enabled by default in the Crypto section of Cloudflare. While this enables your domain to take advantage of SSL, Page Rules allows you to enforce all visitors to connect to your domain securely.  Be advised that some default WordPress configurations may result in some content being served over HTTP, which would result in mixed content errors.  Learn more about fixing that here.

Create a Page Rule for HTTP that includes an asterisk before and after your domain, and select

  • If the URL matches - http://*example.com/*
  • CLICK "+ A Setting" and select "Always Use HTTPS"
  • Make sure the ORDER is set to FIRST
  • CLICK Save and Deploy

More details can be found in this article.

 

301/302 Forwarding URL

Here are two common examples for using Forwarding URLs.  

If you want to define the root as the canonical version of your domain, create a Page Rule that includes the following:

  • If the URL matches - *www.example.com/*
  • CLICK "+ A Setting" and select "Forwarding URL"
  • Select Status Code - "301 Permanent Redirect"
  • Enter Destination URL - https://example.com/$1
  • CLICK Save and Deploy

Or if you want to direct visitors to a specific page with an easy to remember URL:

  • If the URL matches - *www.example.com/fb*
  • CLICK "+ A Setting" and select "Forwarding URL"
  • Select Status Code - "302 Temporary Redirect"
  • Enter Destination URL - https://www.facebook.com/username
  • CLICK Save and Deploy

  

Security & Cache Level

Certain sections of a website, like the login or admin section, have different security and performance requirements than your general public facing pages.

With Page Rules, you can target these directories make sure they behave the way you want:

  • If the URL matches - example.com/user*
  • CLICK "+ A Setting" and select "Security Level"
  • Select - "High"
  • CLICK "+ A Setting" and select "Cache Level"
  • Select - "Bypass"
  • CLICK "+ A Setting" and select "Disable Apps"
  • CLICK "+ A Setting" and select "Disable Apps"
  • CLICK Save and Deploy

 

Edge Cache TTL & Browser Cache TTL

Certain resources on your domain will likely not change often. For these resources, taking advantage of aggressive caching options can significantly reduce the load on your server and bandwidth utilization.

In this example, the target is a folder that holds the majority of the image assets as well as some other types of multimedia.

  • If the URL matches - example.com/sites/default/files*
  • CLICK "+ A Setting" and select "Browser Cache TTL"
  • Select - "a day"
  • CLICK "+ A Setting" and select "Cache Level"
  • Select - "Cache Everything"
  • CLICK "+ A Setting" and select "Edge Cache TTL"
  • Select - "7 days"

In this example, you can apply unique rules for critical pages that don't change very often.

  • If the URL matches - example.com/terms-of-service
  • CLICK "+ A Setting" and select "Browser Cache TTL"
  • Select - "a day"
  • CLICK "+ A Setting" and select "Always Online"
  • Select - "On"
  • CLICK "+ A Setting" and select "Cache Level"
  • Select - "Cache Everything"
  • CLICK "+ A Setting" and select "Edge Cache TTL"
  • Select - "a month"

By following the Page Rules outlined here, your domain can take better advantage of Cloudflare’s features that increase the security, performance, and reliability of your property.

Still not finding what you need?

The Cloudflare team is here to help. 95% of questions can be answered using the search tool, but if you can’t find what you need, submit a support request.

Powered by Zendesk