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.
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:
-
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 setting Modern home Forwarding URL (301/302) Redirect Rule (dynamic) Cache Level (Bypass / Cache Everything / Standard) Cache Rule (with cache: falsefor Bypass, custom eligibility for Cache Everything)Edge Cache TTL Cache Rule → Edge TTL override Browser Cache TTL Cache Rule → Browser TTL override SSL (Off / Flexible / Full / Strict) Configuration Rule → SSL Always Use HTTPS Configuration Rule (the global toggle still exists, but per-path overrides move here) Host Header Override Origin Rule Resolve Override Origin Rule Disable Apps / Performance / Security Configuration Rule Bypass Cache on Cookie Cache Rule with an expression on http.cookieCustom Cache Key Cache Rule → Cache Key block -
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/*tohttps://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))and301as the status code. The5is 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. -
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 expressionstarts_with(http.request.uri.path, "/admin/")and an override ofemail_obfuscation: off. -
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 → 443This 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. -
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). -
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 -Ion a sample URL. Thecf-cache-status, redirect chain, andcf-rayheader tell you which path the request took. After 24-48 hours of clean traffic, delete the legacy Page Rule.
Common pitfalls
- Wildcards behave differently. A Page Rule pattern of
*example.com/blog/*matched subdomains; the modern equivalent requires an explicithttp.hostclause or awildcard_matchexpression. - 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-Controlwhich 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.