Overview
Cloudflare Page Rules give you granular control over how Cloudflare settings are applied to specific URLs or sections of your website. Instead of applying a setting site-wide, you can define custom behaviours for individual pages—such as bypassing the cache for your admin panel, enforcing HTTPS for sensitive login pages, or setting up custom URL redirects.
This feature is essential for optimising both performance and security by ensuring that each part of your site is handled with the appropriate level of caching and protection.
Step-by-Step:
- Login to your Client Area account
- Navigate to Cloud Services > My Products & Services and select your Cloudflare service.
- On the left-hand sidebar, click on the Rules dropdown and select Page Rules.
- On the Page Rules dashboard, click the blue + Create Rule (or + Create Page Rule) button.
- Define the URL Pattern: In the “If the URL matches” field, enter the URL or pattern you want to target. You can use wildcards (the asterisk * character) for flexibility:
- Exact Match: example.com/contact (applies only to that specific page).
- Directory Match: example.com/blog/* (applies to every page within the blog section).
- Catch-all Match: *example.com/* (applies to the entire domain and all subdomains).
- Click the “Pick a Setting” dropdown menu and select the feature you want to modify (e.g., Cache Level, Security Level, or Forwarding URL).
- Select the desired action or value for that setting:
- Forwarding URL: Choose a status code (301 Permanent or 302 Temporary) and enter the destination URL.
- Cache Level: Select Bypass for admin areas or Cache Everything for static landing pages.
- Security Level: Choose High or Under Attack for login endpoints.
- If you need to apply multiple settings to the same URL pattern, click + Add a Setting.
- Once finished, click Save and Deploy Page Rule to activate the configuration immediately.
Managing Rule Priority
Cloudflare processes Page Rules in descending order, from top to bottom. Only the first rule that matches a URL will be applied.