Back to Cloudflare

Change Requests With the Modern Rules Engine

November 4, 2026 Updated November 6, 2026 Wasil Zafar 25 min read

Choose redirects, rewrites, origin settings, or code deliberately

Table of Contents

  1. Match Requests With Expressions
  2. Redirects, Rewrites, Headers, and Origin Rules
  3. Configuration Rules and Small Snippets
  4. Migrating Page Rules Without Assuming the Same Order
  5. Implement a Redirect and Header Rewrite for a Test Path
  6. Trace Rule Matches and Check for Loops

Match Requests With Expressions

Picture a mailroom. Every envelope arrives with a routing slip: destination, sender, service class. A clerk does not open the letter. They compare the slip with a short list of questions and stamp a handling instruction on the front. The contents never matter; the slip does.

Cloudflare's Rules products work the same way. A request arrives carrying attributes: hostname, path, method, query string, country, cookies, headers. A rule pairs a yes/no question about those attributes with an action. The question is the rule's expression; the action is the change.

Take one concrete request: GET https://shop.example.com/old-docs/setup?ref=email. This expression matches it:

http.host eq "shop.example.com" and http.request.method eq "GET" and starts_with(http.request.uri.path, "/old-docs/")

Anatomy of that expression. Three fields, two comparison operators, one function. The path excludes the query string; the full URI includes both scheme and query, a distinction that matters when migrating URL patterns.

Four terms carry the rest of the article:

  • A field is a request or response property the rules engine exposes, such as http.request.uri.path or ip.src.country.
  • An expression is a boolean formula. It must evaluate to true for the action to run.
  • A phase is an ordered slot in the request pipeline. Each product owns a phase, and phases run in a fixed sequence.
  • An action is what changes: a redirect, a rewrite, a header edit, an origin override, or a setting change. Terminating actions (redirect, block, challenge) stop evaluation immediately. Non-terminating actions change a value and let the request continue.

The mental model is three questions: does it match, what does it change, and when does it run. Teams usually get the first two right and forget the third. A rule is not only a condition; it is a condition attached to a moment.

String comparisons are case-sensitive by default. Wrap the field in lower() when case must not decide the match.

Matchers differ in scope. contains tests a substring, while wildcard matches the entire value case-insensitively.

The asterisk is the wildcard metacharacter. It stands for any run of characters, but the pattern must describe the whole value.

Regex is plan-gated. matches evaluates a regular expression on Business and Enterprise plans.

Boolean composition is explicit. Combine conditions with the boolean operators and parentheses. A literal true matches every request at that phase: useful as a baseline, dangerous as a catch-all.

Match Requests With Expressions
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','titleColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','activationBorderColor':'#132440','signalColor':'#5a6e82','signalTextColor':'#132440','noteBkgColor':'#c4873b','noteTextColor':'#132440','noteBorderColor':'#132440','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
    R["GET https://shop.example.com/old-docs/setup?ref=email"] --> F["Fields: http.host, http.request.method,
http.request.uri.path"] F --> E{"Expression evaluates true?"} E -->|"false"| N["Evaluate the next rule
in the same phase"] E -->|"true"| P["Phase: http_request_dynamic_redirect"] P --> A{"Action type"} A -->|"redirect (terminating)"| X["3xx + Location returned
evaluation stops"] A -->|"rewrite, header, origin"| C["Value changes for later phases"] C --> O["Origin receives the modified request"] N --> E2{"Later rule matches?"} E2 -->|"yes"| P E2 -->|"no"| O classDef primary fill:#132440,color:#ffffff,stroke:#0b172b; classDef secondary fill:#16476A,color:#ffffff,stroke:#0f314a; classDef ok fill:#3B9797,color:#ffffff,stroke:#2a6f6f; classDef danger fill:#BF092F,color:#ffffff,stroke:#7a0420; classDef warn fill:#c4873b,color:#132440,stroke:#8a5a1f; class O primary; class R,F,E,N,P,A,X,C,E2 secondary;

Figure 1 shows the two exits from a rule: a terminating action leaves the pipeline, while a non-terminating action changes what the next phase sees.

Figure 2 places those phases on the boundary between visitor and origin. The browser speaks to the edge; the edge decides whether the request continues at all. A redirect turns it around. A rewrite, header edit, or origin override keeps it moving.

Where redirects, rewrites, headers, and origin rules act between browser and origin Rules evaluate inside the Cloudflare edge pipeline. A redirect returns to the browser and ends the request; rewrites, header changes, and origin overrides continue toward the origin. The edge sits between two parties and two ideas of the URL Browser shows the URL re-requests on 3xx Cloudflare edge: ordered phases Single Redirect http_request_dynamic_redirect URL Rewrite http_request_transform Configuration and Origin Rules http_config_settings / http_request_origin Cache Rules http_request_cache_settings Snippets http_request_snippets (JavaScript) Origin sees rewritten path, headers, target host 3xx returns to the client A redirect ends the request here. The other actions continue.

The distinction is not cosmetic. A redirect changes the client's idea of the URL; a rewrite changes the origin's idea of the path; an origin rule changes Cloudflare's idea of the server; a header change alters what the origin is told. Choosing wrong produces working-but-wrong behavior that survives review because the page still renders.

Redirects, Rewrites, Headers, and Origin Rules

Use one request to compare the products. A visitor opens https://shop.example.com/old-docs/setup?ref=email after a documentation move.

ChoiceConcrete effectVisitor seesPhasePlan boundary
Single RedirectReturns 308 with Location: https://shop.example.com/docs/setup; the origin never sees the old pathA new URL and a second requesthttp_request_dynamic_redirectAll plans; 10/25/50/300 rules by plan; regex on Business and Enterprise
URL RewriteSends GET /content/docs/setup to the origin; relative links resolve against the old URLThe same URL, different contenthttp_request_transformAll plans; Transform Rules share 10/25/50/300 active rules
Request header transformSets x-docs-route: v2 so the origin can pick an application version; the path is untouchedNothinghttp_request_late_transformAll plans; shares the Transform Rules quota
Response header transformSets, adds, or removes headers sent to the browserResponse headers onlyhttp_response_headers_transformAll plans; shares the Transform Rules quota
Origin RuleConnects to a different resolved hostname, port, Host header, or SNI value; splits one hostname across backendsNothing, unless the backend differshttp_request_originAll plans; Host, SNI, and DNS override are Enterprise-only; port is all plans
Configuration RuleApplies a zone setting such as SSL mode or PolishIndirect, through the settinghttp_config_settingsAll plans; 10/25/50/300 rules

The trade is round trips against URL stability. A redirect costs a second request but updates bookmarks and consolidates search signals. A rewrite saves the round trip but leaves relative links resolving against the old path. Header and origin rules are invisible to the visitor, which is what makes them hard to debug.

The boundary in one line

A redirect is answered by Cloudflare and never reaches your server. A rewrite changes the URI that reaches your server. An origin rule changes which server receives it. A header rule changes the metadata attached to it.

Status codes are part of the contract. Two axes matter: whether the method survives, and whether the client remembers the answer.

CodeMethodDurationUse it when
301May switch POST to GETPermanent; browsers cache aggressivelyThe target is final and you accept client-side caching
302May switch POST to GETTemporaryYou are validating a change
307PreservedTemporaryYou are validating a change and the method must survive
308PreservedPermanent; browsers cache aggressivelyThe target is final and the method must survive

Dashboard defaults that bite

The dashboard defaults to 301, and Preserve query string is off (Single Redirects settings). A wrong permanent redirect can outlive the deploy that introduced it.

Validate with 302 or 307 instead. Response header transforms also cannot change caching: Cloudflare evaluates cache behavior before applying them, so use a Cache Rule for that.

Figure 3 follows the two paths as a sequence, including the two failures that account for most incidents: a redirect whose target still matches its own expression, and a second rewrite that evaluates the original path.

Redirects, Rewrites, Headers, and Origin Rules
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','activationBorderColor':'#132440','signalColor':'#5a6e82','signalTextColor':'#132440','noteBkgColor':'#c4873b','noteTextColor':'#132440','noteBorderColor':'#132440','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
sequenceDiagram
    participant B as Browser
    participant E as Cloudflare edge
    participant O as Origin
    B->>E: GET /old-docs/setup?ref=email
    E->>E: Single Redirect expression matches
    alt Redirect action
        E-->>B: 308, Location /docs/setup
        B->>E: GET /docs/setup (second request)
        E->>E: Redirect no longer matches
        E->>O: GET /docs/setup
        O-->>E: 200
        E-->>B: 200
    else No redirect, rewrite matches
        E->>E: path becomes /content/docs/setup
        E->>O: GET /content/docs/setup
x-docs-route: v2 O-->>E: 200 E-->>B: 200, URL unchanged end Note over E: Loop: target /docs/setup still matches /docs/* Note over E: Double rewrite: rule 2 reads the original path, then overwrites

Three views, one intent. The tabs below show the same redirect and rewrite as Terraform and as a Snippet; the Bash widget that follows creates them through the Rulesets API. The Snippet path needs a paid plan because Snippets are Pro and above; the API path works on every plan.

resource "cloudflare_ruleset" "lab_redirect" {
  zone_id = var.zone_id
  name    = "lab redirects"
  kind    = "zone"
  phase   = "http_request_dynamic_redirect"

  rules = [{
    ref        = "lab_old_docs_redirect"
    expression = "(http.request.method eq \"GET\" or http.request.method eq \"HEAD\") and http.request.uri.path eq \"/old-docs/setup\""
    action     = "redirect"
    action_parameters = {
      from_value = {
        target_url            = { value = "https://lab.example.com/docs/setup" }
        status_code           = 308
        preserve_query_string = true
      }
    }
  }]
}

resource "cloudflare_ruleset" "lab_rewrite" {
  zone_id = var.zone_id
  name    = "lab rewrites"
  kind    = "zone"
  phase   = "http_request_transform"

  rules = [{
    ref        = "lab_docs_rewrite"
    expression = "starts_with(http.request.uri.path, \"/docs/\")"
    action     = "rewrite"
    action_parameters = {
      uri = {
        path = { expression = "concat(\"/content\", http.request.uri.path)" }
      }
    }
  }]
}
export default {
  async fetch(request) {
    const url = new URL(request.url);

    // Terminating action: the browser must re-request /docs/setup.
    if (url.pathname === "/old-docs/setup") {
      return Response.redirect(new URL("/docs/setup", url).toString(), 308);
    }

    // Non-terminating action: the origin sees /content/docs/setup.
    if (url.pathname.startsWith("/docs/")) {
      const target = new URL(request.url);
      target.pathname = `/content${url.pathname}`;

      const headers = new Headers(request.headers);
      headers.set("x-docs-route", "v2");

      const init = { method: request.method, headers };
      if (request.method !== "GET" && request.method !== "HEAD") {
        init.body = request.body;
      }
      return fetch(target.toString(), init);
    }

    return fetch(request);
  },
};

The same rules through the API. The shell panel creates one ruleset per phase; the header transform is the third phase, so its expression matches the rewritten path.

set -euo pipefail
  # Needs ZONE_ID and CF_API_TOKEN with Single Redirect Edit
  # and Transform Rules Edit on the zone.
BASE="https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/rulesets"

curl -sS -X POST "$BASE" \
  -H "Authorization: Bearer ${CF_API_TOKEN}" \
  -H "Content-Type: application/json" \
  --data @- <<'JSON'
{
  "name": "lab redirects",
  "kind": "zone",
  "phase": "http_request_dynamic_redirect",
  "rules": [
    {
      "ref": "lab_old_docs_redirect",
      "expression": "(http.request.method eq \"GET\" or http.request.method eq \"HEAD\") and http.request.uri.path eq \"/old-docs/setup\"",
      "action": "redirect",
      "action_parameters": {
        "from_value": {
          "target_url": { "value": "https://lab.example.com/docs/setup" },
          "status_code": 308,
          "preserve_query_string": true
        }
      }
    }
  ]
}
JSON

curl -sS -X POST "$BASE" \
  -H "Authorization: Bearer ${CF_API_TOKEN}" \
  -H "Content-Type: application/json" \
  --data @- <<'JSON'
{
  "name": "lab rewrites",
  "kind": "zone",
  "phase": "http_request_transform",
  "rules": [
    {
      "ref": "lab_docs_rewrite",
      "expression": "starts_with(http.request.uri.path, \"/docs/\")",
      "action": "rewrite",
      "action_parameters": {
        "uri": { "path": { "expression": "concat(\"/content\", http.request.uri.path)" } }
      }
    }
  ]
}
JSON

curl -sS -X POST "$BASE" \
  -H "Authorization: Bearer ${CF_API_TOKEN}" \
  -H "Content-Type: application/json" \
  --data @- <<'JSON'
{
  "name": "lab header transform",
  "kind": "zone",
  "phase": "http_request_late_transform",
  "rules": [
    {
      "ref": "lab_docs_header",
      "expression": "starts_with(http.request.uri.path, \"/content/docs/\")",
      "action": "rewrite",
      "action_parameters": {
        "headers": {
          "x-docs-route": { "operation": "set", "value": "v2" }
        }
      }
    }
  ]
}
JSON

Two details are deliberate. The header rule matches the rewritten path, because header transforms run later and see the change. The redirect names a complete absolute target; a relative target is rejected. To match the original path later, use raw.http.request.uri.path, which stays immutable. The shell panel creates a new phase ruleset; if one already exists, update it rather than POST a duplicate.

Availability is per product, not per zone. Redirects, rewrites, header transforms, configuration rules, compression rules, and origin rules all have a free tier, but with different quotas and features. Origin Host, SNI, and DNS overrides are Enterprise-only even though the product is on every plan. Regex starts at Business. Snippets start at Pro. Check the table for the account you are deploying to before promising behavior.

Configuration Rules and Small Snippets

Page Rules did many jobs. Modern rules fan them out across products that each own a phase; the mapping is mechanical once you name the job:

Modern productPage Rules jobs it replaces
Single RedirectForwarding URL, Always Use HTTPS
Origin RulesHost Header Override, Resolve Override
Cache RulesCache Level, Edge Cache TTL, Browser Cache TTL, Cache on Cookie, Bypass Cache on Cookie, Cache Deception Armor, Query String Sort
Configuration RulesSSL, Security Level, Browser Integrity Check, Email Obfuscation, Hotlink Protection, Rocket Loader, Polish, Opportunistic Encryption
Managed TransformsIP Geolocation Header, True Client IP Header

That is the feature-correspondence table in Cloudflare's Page Rules migration guide, the authoritative source when a setting is ambiguous.

Page Rules are legacy, not merely old. They match only on URL patterns, so method, header, cookie, and country conditions are impossible. Their quota is small: 3 on Free, 20 on Pro, 50 on Business, 125 on Enterprise (Page Rules).

First-match-wins does not scale. Several actions inside one rule apply in a customer-chosen sequence, which makes a 40-rule zone hard to reason about. Modern rules are stackable, each product has its own quota, and modern rules take precedence over Page Rules. Workers are the exception in the other direction: a Worker suppresses Page Rules but not modern Rules features.

Snippets are the other end of the spectrum. They run short JavaScript in the http_request_snippets phase, on Pro (25), Business (50), and Enterprise (300) (Snippets).

The limits are tight. A 5 ms maximum execution time, 2 MB of memory, a 32 KB package limit, and 2/3/5 subrequests by plan. Multiple snippets run sequentially, each seeing the previous one's changes. Version Management does not cover them.

Code vs configuration

Code earns its place when a table cannot express the decision: validating a JWT, choosing an A/B bucket from a cookie, rewriting links in an HTML body, or retrying against a second origin. For a static path mapping, a header set, or an origin switch, the declarative product is cheaper per request, visible in the simulator, and reviewable by someone who does not read JavaScript. A rule that does not match costs one predicate evaluation; a snippet that matches costs its execution budget on every request.

Compression Rules are a product that already exists. They run in the response phase, choose the first algorithm the browser accepts, and the last matching rule wins. They are skipped when the origin sends Cache-Control: no-transform, and they do nothing if the browser accepts none of the listed algorithms (Compression Rules).

Migrating Page Rules Without Assuming the Same Order

Consider a composite documentation site. Forty Page Rules accumulated over six years (composite scenario, not a named customer). The top rule, *example.com/docs/*, forwards permanently to /documentation/$1.

The rest covers assets and defaults. Below it, /assets/* sets Cache Everything with a one-day edge TTL. Near the bottom, a catch-all enables Always Use HTTPS and SSL Full. A separate API hostname rule overrides the Host header.

Only the highest-priority match runs. A request to /docs/install hits the first rule and redirects; the cache and SSL actions on lower rules never participate. If someone drags Always Use HTTPS above it, the docs redirect stops firing. Nothing in the rule text explains that, because priority lives in list order.

Modern rules split that list into product lanes. The fixed sequence is Single Redirects, URL Rewrite, Configuration Rules, Origin Rules, Bulk Redirects, Managed Transforms, Request Header Transforms, Cache Rules, Snippets, Cloud Connector (execution order). Within a lane, order is yours; across lanes, it is not.

Two consequences follow. Within the redirect phase the first match wins and ends evaluation, so a broad rule above a narrow exception shadows it. A redirect also terminates before the cache phase, so a cache rule matching only the pre-redirect path never runs for redirected requests.

Migrate in five steps.

  1. Inventory every Page Rule: pattern, actions, enabled state, position.
  2. Classify each action by product and convert the pattern to an expression.
  3. Split multi-action rules and predict the fixed product order.
  4. Deploy alongside the Page Rule, then disable — do not delete — the old rule.
  5. Compare with the Rules simulator and curl -sSI, then delete the Page Rule.

Schemes are explicit in modern expressions. Page Rules URLs without a scheme match both HTTP and HTTPS; the full-URI field requires one. Prefix the pattern with http*://.

Query strings are included unless you exclude them. Page Rules ignore query strings unless the pattern includes one; the full-URI field includes them. Append * if the query must not affect matching.

A worked conversion. Cloudflare's own example turns example.com/*/downloads/*.txt into http.request.full_uri wildcard "http*://example.com/*/downloads/*.txt*" (migration guide).

Figure 4 contrasts the two models. On the left, one Page Rule carries four actions and lower rules never evaluate. On the right, the same intent becomes rules in four phases — and the redirect ends the request before the cache rule can apply.

One Page Rule with four actions compared with four modern rules in fixed phases Page Rules apply the first matching rule and run its actions in a customer-chosen order. Modern rules split the actions across phases; a redirect terminates before the cache phase runs. Before: one matched rule, four actions Rule 1: *example.com/docs/* Forwarding URL 301 Cache Everything Edge TTL: 1 day SSL: Full Rule 2: *example.com/assets/* never evaluated for /docs/* Rule 3: *example.com/* never evaluated for /docs/* First match wins. Actions run in the order chosen inside the rule. After: four rules, fixed phases Single Redirect /docs/* to 308 /documentation/* URL Rewrite: no rule Configuration Rule SSL: Full Origin Rule Host override for api.example.com Cache Rules: matches /assets/*, not the redirected /docs/* request Redirect terminates: the cache phase never runs.

Two redirect loops to expect

A mixed state is the most common migration loop. A modern redirect sends HTTP traffic back to HTTP (a missing scheme or copied destination), the catch-all Always Use HTTPS Page Rule sends it to HTTPS, and the modern rule matches again.

The visitor sees ERR_TOO_MANY_REDIRECTS and the origin sees nothing. Fix the target scheme, then exclude the destination from the source expression.

A prefix redirect can loop inside its own target. A redirect from the docs prefix to a versioned prefix also matches the versioned path, producing a doubled segment such as /docs/v2/v2/install.

Add and not starts_with(http.request.uri.path, "/docs/v2/") to the source expression.

Two boundary conditions remain. Some Page Rules settings do not migrate at all: Disable Performance, Disable Railgun, Disable Security, Response Buffering, and Web Application Firewall are deprecated or have no modern equivalent. And automatic migration is still described as planned, with advance notification and no action required; the guide gives no completion date, so confirm the state in your dashboard.

The tradeoff is real. You trade one ordered list for several product-specific lists and a fixed cross-product order you cannot change. You gain conditions beyond URLs, larger quotas, Terraform versioning, and a simulator that explains which rule matched. The order you lose control over was never explicit in the first place.

Implement a Redirect and Header Rewrite for a Test Path

This exercise separates a redirect from a header rewrite and shows why their observability differs. It is design-only: it has not been executed, and the observations are documented expectations, not measurements.

Design-only lab

Implement a Redirect and Header Rewrite for a Test Path

Status: design-only. Not executed for this article; expected results come from documented phase order and redirect semantics, not a hosted run. Inputs: a Cloudflare domain with a proxied test host such as lab.example.com, plus an origin fixture you control; use invented data only. Free covers the redirect and header transform, while the Snippet variant needs Pro.

Fixture. The origin returns a small body and echoes the path and the x-docs-route header. It answers the old path and the rewritten path; no cookies, no production content.

Steps.

  1. Baseline: curl -sSI https://lab.example.com/docs/setup returns 200, no Location, no x-docs-route.
  2. Add a Single Redirect for http.request.uri.path eq "/old-docs/setup" to https://lab.example.com/docs/setup, status 308, preserve query string.
  3. Add a URL Rewrite for starts_with(http.request.uri.path, "/docs/") with dynamic path concat("/content", http.request.uri.path).
  4. Add a request header transform for starts_with(http.request.uri.path, "/content/docs/") setting x-docs-route: v2.
  5. Request /old-docs/setup without following: expect 308 and a Location ending in /docs/setup.
  6. Request /docs/setup: expect body path=/content/docs/setup, x-docs-route: v2, status 200, unchanged URL. Repeat with -H "x-docs-route: client-value"; the rule overwrites, not appends.
  7. Inspect both requests in the simulator and confirm the matching phase.

Expected observations. The redirect produces two requests and a visible URL change. The rewrite produces one request, an unchanged URL, and a different origin path. The header rule produces no visible change except at the origin; the echo is the only proof it ran.

Failure check one. Disable the header rule; x-docs-route disappears.

Failure check two. Point the redirect at the old path; the Location points back at itself and following it loops.

Failure check three. Add a second rewrite setting /legacy/docs/setup; the origin receives that value, not the first rewrite's — the double-rewrite behavior from Figure 1.

Cost and cleanup. Domain, fixture, and roughly 30 to 45 minutes; requests are negligible and the rule path needs no paid plan. Delete the three rules, re-run step 1, then remove the fixture routes and test DNS record. No cache purge is needed because this exercise does not enable caching.

Trace Rule Matches and Check for Loops

Pass/fail evidence for the exercise, recorded per request:

  • Pass: /old-docs/setup returns 308, Location points at /docs/setup, and the origin logs no request for the old path.
  • Pass: /docs/setup returns 200, the address bar is unchanged, the origin sees /content/docs/setup, and the echoed header is exactly v2.
  • Pass: with both rules live, the simulator lists the redirect in the redirect phase and the header rule in the late transform phase, in that order.
  • Fail: a 301 or 302 where the method must survive; a Location that points back into the matched prefix; a header echoed twice; a second rewrite that produces the first rewrite's output rather than its own.
  • Inconclusive: a 200 with the right body but no header — the fixture may not echo headers, so verify at the origin first.

Self-check, with explanations:

  1. Why did the second URL Rewrite ignore the first one's result? Within a phase, every filter reads the same immutable snapshot. The second rule's expression evaluated the original path, and its action replaced the first rule's path. To see the original path in a later phase, use raw.http.request.uri.path; to compose rewrites, do the work in one expression or one Snippet.
  2. Why did the Cache Rule stop matching after the rewrite? Cache Rules run in http_request_cache_settings, after the rewrite phase, so their filters see the rewritten path. A rule written for /docs/* will not match a request rewritten to /content/docs/*. Match the destination, or use a raw field if the original path is the stable identifier.
  3. Why does a permanent redirect keep sending traffic to the wrong place after a fix? Browsers cache 301 and 308 responses. The edge change is immediate; the client's memory is not. Prefer 302 or 307 while validating, and reserve 301/308 for a target you are confident about.
  4. Why did the Page Rule appear to do nothing? Modern rules take precedence over Page Rules when both match, and a Worker suppresses Page Rules but not modern rules. The Page Rule may be live and still have no effect.

Unresolved limitations. Documentation was verified on 2026-11-04; the planning baseline was 2026-11-02 and the exercise was not executed, so no hosted result, plan-specific result, latency, or redirect-count measurement is claimed. No product versions were tested because no lab ran. The Rules simulator is Beta and requires an Administrator or Super Administrator role, so its output is not a production log. Browser redirect caching varies by browser and prior visits. Loop-detection behavior was not tested; the loop guidance comes from rule semantics and documented phase order, not an observed failure. Quotas and plan features change; re-check them for your account. Snippet timing and subrequest behavior are documented limits, not measurements.

References: Cloudflare Rules, Rules language: rules and field values, Phases list, Single Redirects, Single Redirects settings, URL Rewrite Rules, Request Header Transform Rules, Response Header Transform Rules, Origin Rules, Configuration Rules, Compression Rules, Snippets, How Snippets work, Snippets vs Workers, Page Rules, Page Rules migration guide, Troubleshoot Rules, Rules simulator, and Rulesets API.

Next in the Series

In Why a CDN Cache Hit Changes the Request Journey, we'll explore Learn cacheability, freshness, validators, and origin behavior.