Introduction

Cloudflare Page Rules allow you to customize behavior for specific URL patterns, but when rules don't apply as expected, troubleshooting requires understanding pattern matching, rule priority, and interaction with other Cloudflare features. Page rules process in order from most specific to least specific, and only one rule can apply per request. Common issues include incorrect wildcards, rules being overridden by other settings, or URL patterns that don't match actual request paths.

Symptoms

  • Page rule settings not applied to matching URLs
  • Cache level overrides not working
  • Redirect rules not triggering
  • Security level changes ineffective
  • Rule applied to wrong URLs unexpectedly
  • Multiple rules expected but only one applies

Common Causes

  • URL pattern syntax error (missing wildcard, wrong format)
  • Rule order causing less specific rule to apply first
  • URL pattern includes query string but actual requests don't
  • Other Cloudflare features overriding page rule settings
  • Page rule limited to first matching rule only
  • Pattern doesn't account for trailing slashes
  • Cache Rules or Configuration Rules taking precedence

Step-by-Step Fix

  1. 1.Verify the exact URL pattern requests use:

```bash # Check actual request URL curl -v https://yourdomain.com/path/to/page

# Note exact path including: # - Leading slash # - Trailing slash or no trailing slash # - Query strings # - Case sensitivity ```

  1. 1.Test which rule matches your URL:

In Cloudflare Dashboard > Rules > Page Rules: - Each rule shows a URL pattern - Cloudflare matches patterns in order (top to bottom) - First matching rule applies, others ignored

bash
# Verify pattern syntax
# Example patterns:
# yourdomain.com/*          - matches all paths
# yourdomain.com/blog/*     - matches /blog/ and subpaths
# yourdomain.com/api/*      - matches /api/ paths
# yourdomain.com/exact      - matches exact path only
  1. 1.Check wildcard placement:

``` # Correct wildcard usage: yourdomain.com/blog/* # Matches /blog/, /blog/post, /blog/category/tech

# Incorrect patterns: yourdomain.com/blog* # Won't match /blog/post (missing slash) *.yourdomain.com/blog # Wrong - wildcard at start for subdomains yourdomain.com/*blog # Partial match, unreliable ```

  1. 1.Account for trailing slash variations:

``` # To match both /path and /path/: yourdomain.com/path*

# Or create separate rules: yourdomain.com/path # Matches /path exactly yourdomain.com/path/* # Matches /path/ and subpaths ```

  1. 1.Reorder rules for correct priority:

In Cloudflare Dashboard: - Drag rules to reorder - More specific patterns should be higher (first) - Generic catch-all rules should be last

  1. 1.`
  2. 2.# Good order:
  3. 3.yourdomain.com/admin/* - specific admin override
  4. 4.yourdomain.com/api/* - API specific settings
  5. 5.yourdomain.com/* - catch-all default
  1. 1.# Bad order:
  2. 2.yourdomain.com/* - matches everything first
  3. 3.yourdomain.com/admin/* - never reached
  4. 4.`
  1. 1.Check for conflicting settings:
bash
# Settings that can override page rules:
# - Cache Rules (newer, takes precedence)
# - Configuration Rules
# - Origin Rules
# - WAF custom rules
# - SSL/TLS settings (Always Use HTTPS)

Navigate to each section and check for conflicting configurations.

  1. 1.Verify page rule settings are enabled:

In page rule: - Ensure "Cache Level" is set if caching behavior expected - Check "Edge Cache TTL" is configured - Verify "Browser Cache TTL" if needed - Confirm other settings aren't conflicting (SSL vs Always Use HTTPS)

  1. 1.Test rule application with verbose request:

```bash # Test and check headers curl -Iv https://yourdomain.com/path/

# Look for indicators of rule application: # - Cache headers (TTL values) # - SSL settings # - Security challenge behavior ```

  1. 1.Check for Cache Rules taking precedence:

Navigate to: Caching > Cache Rules

```bash # Cache Rules evaluate before Page Rules # If a Cache Rule matches, it may override Page Rule cache settings

# Either disable conflicting Cache Rule # Or adjust Cache Rule to not conflict with Page Rule ```

  1. 1.Verify page rule limits per plan:

``` # Free: 3 page rules # Pro: 20 page rules # Business: 100 page rules # Enterprise: unlimited

# If limit exceeded, older rules may not work ```

  1. 1.Use API to verify rule configuration:

```bash curl -X GET "https://api.cloudflare.com/client/v4/zones/ZONE_ID/pagerules" \ -H "Authorization: Bearer API_TOKEN"

# Check rule status and configuration ```

Verification

After applying fixes:

  1. 1.curl -I https://yourdomain.com/path/ shows expected cache headers
  2. 2.Page rule settings reflected in response headers
  3. 3.Rule matches correct URLs based on pattern
  4. 4.More specific rules apply before generic rules
  5. 5.No conflicting settings override page rule behavior