Skip to content

Migrating from Page Rules to modern Cloudflare rules

Page Rules are deprecated. Map each common pattern to the four replacements (Cache Rules, Configuration Rules, Origin Rules, Redirect Rules), then run the conversion in a safe order without losing traffic.

A zone has 23 Page Rules accumulated over five years. They cache HTML for the marketing site, force HTTPS on a legacy subdomain, rewrite the origin host for /api, and 301 a long tail of old WordPress slugs. Cloudflare deprecated Page Rules in 2024 and the migration window won’t stay open forever. This article maps the patterns one by one, in the order that minimises risk: read-only rules first, traffic-shaping last.

How to verify

List every Page Rule in the zone and inspect the existing modern rulesets so you can see what’s already migrated and what isn’t:

ZONE_ID=$(curl -s -H "Authorization: Bearer $CF_API_TOKEN" \
  "https://api.cloudflare.com/client/v4/zones?name=example.com" \
  | jq -r '.result[0].id')

# Legacy Page Rules
curl -s -H "Authorization: Bearer $CF_API_TOKEN" \
  "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/pagerules" | jq

# Modern rulesets (one per phase)
curl -s -H "Authorization: Bearer $CF_API_TOKEN" \
  "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/rulesets" \
  | jq '.result[] | {id, name, phase, kind}'

The phases to look for are http_request_cache_settings (Cache Rules), http_config_settings (Configuration Rules), http_request_origin (Origin Rules), and http_request_dynamic_redirect (Redirect Rules). The dashboard mirror lives under Rules → Overview with a count next to each ruleset.

What’s happening

Page Rules were a single feature that mixed seven kinds of behaviour into one rule type: cache, security, redirect, origin override, header transform, browser cache, and a handful of toggles. The mixing was convenient when there were three rules; it became unmanageable at scale because order mattered globally across unrelated concerns. Cloudflare unbundled the model into four phase-scoped rulesets, each evaluated at a defined point in the request pipeline, with predictable precedence inside the phase.

Page Rules(legacy, deprecated)one rule, many concernsCache Rulescache eligibility, TTL, keyConfiguration RulesSSL, security level, togglesOrigin Ruleshost, port, SNI overridesRedirect RulesPipeline order1. Redirect2. Configuration3. Origin4. Cache
Page Rules unbundle into four phase-scoped rulesets that fire at defined points in the request pipeline.

The replacement model is more verbose but predictable. A modern Redirect Rule cannot accidentally turn off TLS because the action is constrained to redirects. A Cache Rule cannot override the origin host because that action lives in Origin Rules. Each ruleset has its own filter expression language (the same http.host eq "..." syntax used by the WAF), so the matching is consistent across all four.

The procedure

The conversion order matters because Redirect Rules fire before everything else and Cache Rules fire last. Migrate in this sequence:

  1. Inventory and tag. Export every Page Rule via the API call above and label each one with its dominant action — cache, config, origin, redirect, or “mixed”. For mixed rules (e.g. “Forwarding URL + Cache Level”), you’ll create one rule per phase. Keep a spreadsheet of the URL pattern, action, and the new rule it maps to. The mapping table that holds across almost every zone:

    Page Rule settingModern home
    Forwarding URL (301/302)Redirect Rule (dynamic)
    Cache Level (Bypass / Cache Everything / Standard)Cache Rule (with cache: false for Bypass, custom eligibility for Cache Everything)
    Edge Cache TTLCache Rule → Edge TTL override
    Browser Cache TTLCache Rule → Browser TTL override
    SSL (Off / Flexible / Full / Strict)Configuration Rule → SSL
    Always Use HTTPSConfiguration Rule (the global toggle still exists, but per-path overrides move here)
    Host Header OverrideOrigin Rule
    Resolve OverrideOrigin Rule
    Disable Apps / Performance / SecurityConfiguration Rule
    Bypass Cache on CookieCache Rule with an expression on http.cookie
    Custom Cache KeyCache Rule → Cache Key block
  2. Migrate redirects first. They’re the easiest to test (curl shows the new behaviour immediately) and they fire earliest in the pipeline, so getting them right means subsequent rules see the right URL. For a Page Rule that forwarded https://example.com/old/* to https://example.com/new/$1, the Redirect Rule expression is:

    (http.host eq "example.com" and starts_with(http.request.uri.path, "/old/"))

    with a dynamic target of concat("https://example.com/new/", substring(http.request.uri.path, 5)) and 301 as the status code. The 5 is the length of /old/. For lists of more than a handful of redirects, switch to Bulk Redirects — they’re cheaper to evaluate and easier to audit.

  3. Migrate config toggles next. SSL mode overrides, Browser Integrity Check, Email Obfuscation, Hotlink Protection — anything in the old “performance/security” buckets — moves into Configuration Rules. Each Configuration Rule has an expression and a set of overrides. Example: a Page Rule that disabled Email Obfuscation on /admin/* becomes a Configuration Rule with expression starts_with(http.request.uri.path, "/admin/") and an override of email_obfuscation: off.

  4. Migrate origin overrides. Old “Host Header Override” and “Resolve Override” become a single Origin Rule per origin target:

    When: (http.host eq "example.com" and starts_with(http.request.uri.path, "/api/"))
    Then: Host Header → "api-internal.example.com"
          DNS Record → "api-origin.example.com"
          Port → 443

    This is also the place to point a path prefix at a different upstream — e.g. send /static/* to a Pages project while the rest of the zone goes to the legacy origin.

  5. Migrate cache behaviour last. Cache Rules are the trickiest because the new model separates eligibility (should this be cached at all?), TTL (how long?), and cache key (what makes two requests “the same”?). A Page Rule with “Cache Level: Cache Everything” and “Edge Cache TTL: 1 hour” becomes a single Cache Rule:

    When: (http.host eq "example.com" and starts_with(http.request.uri.path, "/blog/"))
    Then: Eligible for cache → Yes
          Edge TTL → Override origin → 3600
          Browser TTL → Respect origin

    “Bypass Cache” becomes a rule with eligibility set to false. Custom cache keys move into the dedicated Cache Key block, which is more capable than Page Rules ever was (you can include/exclude specific cookies, headers, and query string parameters by name).

  6. Disable the Page Rule in pairs. For each migrated Page Rule, disable it (don’t delete yet) and verify the new rule behaviour with curl -I on a sample URL. The cf-cache-status, redirect chain, and cf-ray header tell you which path the request took. After 24-48 hours of clean traffic, delete the legacy Page Rule.

1. Inventorytag each rule2. Redirects301 / 3023. ConfigSSL, toggles4. Originhost, port5. CacheTTL, keyConversion order: low risk to high riskDisable each Page Rule only after the modern rule passes a curl verification.Delete the legacy rule after 24-48 hours of clean traffic.
Migrate in pipeline order — redirects first, cache last — to minimise interaction surprises.

Common pitfalls

  • Wildcards behave differently. A Page Rule pattern of *example.com/blog/* matched subdomains; the modern equivalent requires an explicit http.host clause or a wildcard_match expression.
  • Precedence is per-ruleset, not global. Two rules in different rulesets cannot have a relative priority; each ruleset orders its own rules. If two Cache Rules conflict, the first match wins.
  • “Cache Everything” is no longer a single toggle. It maps to “Eligible for cache: Yes” plus an explicit Edge TTL — without the TTL, you get the origin’s Cache-Control which may be zero.
  • Always Use HTTPS at the zone level is independent. The zone toggle still works after migration; only path-scoped overrides need to move into Configuration Rules.
  • Page Rules and modern rules can coexist for now. Modern rules take effect after the matching Page Rule for the same URL, which can mask bugs. Always disable the Page Rule when verifying the replacement, not just after.

In the Cloudflare engagements we run, this migration is one of the first things we sequence with clients alongside the related Cache Rules cookbook, because Page Rules are usually the layer where forgotten technical debt lives. The audit is the work; the conversion is mechanical. Stack Harbor handles both end to end as part of managed operations.