Skip to main content
Page Rules allow you to customize Cloudflare settings for specific URL patterns in your zone. You can override various settings and behaviors based on the URL of the request.

Create a page rule

Creates a new Page Rule for a zone.
string
required
The zone identifier
array
required
The set of actions to perform if the targets of this rule match the request. Actions can redirect to another URL or override settings, but not both.
array
required
The rule targets to evaluate on each request.
object
String constraint for URL matching
string
required
The matching operator: matches, contains, equals, not_equal, or not_contain
string
required
The URL pattern to match. The pattern may contain up to four asterisks (*) as placeholders.
string
Set to url for URL-based targeting
number
The priority of the rule. A higher number indicates higher priority. Used when multiple Page Rules could match the same URL.
string
The status of the Page Rule: active or disabled

Available actions

Page Rules support numerous actions to customize behavior: Cache settings:
  • browser_cache_ttl - Set browser cache TTL
  • cache_level - Set cache level (bypass, basic, simplified, aggressive, cache_everything)
  • edge_cache_ttl - Set edge cache TTL
  • cache_by_device_type - Cache based on device type
  • cache_deception_armor - Protect from cache deception attacks
  • cache_key_fields - Control cache key variables
  • cache_on_cookie - Cache based on cookie match
  • cache_ttl_by_status - Set TTL by response status code
  • bypass_cache_on_cookie - Bypass cache if cookie matches
  • explicit_cache_control - Origin cache control
Security settings:
  • browser_check - Enable browser integrity check
  • email_obfuscation - Obfuscate email addresses
  • ip_geolocation - Add IP geolocation headers
  • security_level - Set security level
  • waf - Enable/disable WAF
  • disable_security - Turn off security features
Performance settings:
  • automatic_https_rewrites - Rewrite HTTP to HTTPS
  • mirage - Enable Mirage image optimization
  • polish - Enable Polish image compression
  • rocket_loader - Enable Rocket Loader
  • disable_performance - Turn off performance features
Network settings:
  • always_use_https - Redirect HTTP to HTTPS
  • ssl - Set SSL mode
  • opportunistic_encryption - Enable opportunistic encryption
Redirects and overrides:
  • forwarding_url - Redirect to another URL
  • host_header_override - Override host header
  • resolve_override - Override origin address
Other:
  • disable_apps - Turn off Cloudflare Apps
  • disable_zaraz - Turn off Zaraz
  • origin_error_page_pass_thru - Pass through origin error pages
  • response_buffering - Enable response buffering
  • respect_strong_etag - Respect strong ETags
  • sort_query_string_for_cache - Sort query strings
  • true_client_ip_header - Add True-Client-IP header
string
The Page Rule identifier
array
The configured actions for this rule
array
The URL targets for this rule
number
The rule priority
string
The rule status (active or disabled)
string
Timestamp when the rule was created
string
Timestamp when the rule was last modified

Update a page rule

Replaces the configuration of an existing Page Rule. The configuration will exactly match the data provided.
string
required
The Page Rule identifier
string
required
The zone identifier

List page rules

Fetches all Page Rules in a zone.
string
required
The zone identifier
string
Filter by status: active or disabled
string
Field to sort by: status or priority
string
Sort direction: asc or desc
string
Match mode: any or all (when using multiple filters)

Get a page rule

Fetches details of a single Page Rule.
string
required
The Page Rule identifier
string
required
The zone identifier

Edit a page rule

Updates one or more fields of an existing Page Rule.
string
required
The Page Rule identifier
string
required
The zone identifier

Delete a page rule

Deletes an existing Page Rule.
string
required
The Page Rule identifier
string
required
The zone identifier

Example: Set cache TTL and browser check

Example: URL forwarding