Skip to content

SYSTEM Cited by 1 source

Cloudflare Transform Rules

Overview

Cloudflare Transform Rules is a Cloudflare product family for customer-authored edge rules that rewrite requests and responses. Two members relevant to the developers.cloudflare.com agent-readiness refinement:

  • URL Rewrite Rule — rewrites the request URI on an incoming request, before it reaches the origin or a Worker. Supports Cloudflare Rules Language regex_replace() + path / query-string manipulation.
  • Request Header Transform Rule — adds / sets / removes request headers on the request sent to the origin. Can match against raw.http.request.uri.path (the original path before any prior URL-rewrite in the same hop).

Response-side siblings exist (Response Header Transform) but aren't load-bearing in the Cloudflare docs dogfood.

Canonical composed use — dynamic /index.md fallback

Cloudflare's 2026-04-17 docs refinement uses the two Transform Rules together to expose every page at <page>/index.md with no static duplication (patterns/dynamic-index-md-fallback):

  1. URL Rewrite Rule matches requests with path suffix /index.md and strips it (via regex_replace). The request now hits the same origin route as the human page.
  2. Request Header Transform Rule matches raw.http.request.uri.path ends_with "/index.md" (i.e. the original path before the rewrite was applied in this hop) and sets Accept: text/markdown on the rewritten request.

Net result: <page>/index.md responses always carry markdown; no content duplication; cache coherent with the same origin route; no build-step changes; works on the free and paid tiers.

Why the ordering / variable-scoping matters

  • The URL Rewrite Rule rewrites before the origin hop; the Request Header Transform Rule can match on raw.http.request.uri.path, which refers to the path before the rewrite. If the header rule matched http.request.uri.path (post-rewrite), the condition would no longer see /index.md and the Accept header wouldn't be set on the paths that need it.
  • This is a specific composition that requires the Cloudflare Rules-Language split between raw.* and post-rewrite fields — making the pattern portable but Cloudflare-product-specific in its implementation details.

General applicability

Transform Rules enable a general edge-transformation posture:

  • Accept-header normalisation for content-negotiation fallback (this doc).
  • Compatibility redirects without origin code changes.
  • Multi-tenant hostname rewriting.
  • Header-based A/B routing.

For agent-readiness specifically, Transform Rules are the edge lever for adopting markdown content negotiation without touching the origin server or the build pipeline — zero-change integration on top of any existing static-site or CMS.

Seen in

Last updated · 200 distilled / 1,178 read