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.

301/302 Forwarding URL

Security Level & Cache Level

Edge Cache TTL, Always Online, & Browser Cache TTL

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/$2

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.