Skip to content
AnswerWell geo Documentation

Research · 8 min read · Answerwell

URL Redirect Rules, Bulk Lists, Page Rules, and Static _redirects

How to choose and configure HTTP URL redirects at the edge: Single Redirects, Bulk Redirects, Page Rules, and _redirects files.

This page summarizes Cloudflare documentation on URL forwarding (URL redirection): sending visitors from a source URL to a target URL with a specific HTTP status code. Modern setups usually use Single Redirects or Bulk Redirects in the Ruleset Engine; older zones may still use Page Rules or a _redirects file on Pages or Workers with static assets.

Cloudflare offers several ways to perform URL redirects. The choice depends on scale, where traffic is hosted, and how much logic you need.

Option Use when
Single Redirects Default for zone-level rules: one pattern or expression, static or dynamic target.
Bulk Redirects Large numbers of mostly static source→target pairs, often across many domains in one account.
_redirects file Redirects live in the repo/build output for Cloudflare Pages or Workers static assets.
Workers / Snippets Single Redirects and Bulk Redirects are not enough; you need custom JavaScript logic.
Page Rules You already depend on Page Rules for other settings, or you have not migrated Forwarding URL yet.

URL forwarding, also known as URL redirection, navigates the user from a source URL to a target URL with a given HTTP status code.

— Cloudflare, Bulk Redirects

Single Redirects suit expressions, wildcards (${1} captures), and dynamic targets built with functions such as concat() or regex_replace(). Bulk Redirects are essentially static: no string replacement or regular expressions in the list itself, but you can tune matching with redirect parameters and gate lists with rule expressions (for example country-based routing in Redirect requests from one country to a domain).

For alias domains with no real origin, Cloudflare documents placeholder records (for example 192.0.2.1 on a proxied A record) so rules can run before traffic would reach an origin. See Redirect one domain to another and Page Rules.

HTTP status codes: 301, 302, 307, and 308 at the edge

Section titled “HTTP status codes: 301, 302, 307, and 308 at the edge”

Redirects can be generated on Cloudflare’s network without querying the origin for common 3xx responses, including 301, 303, 307, and 308, often via Redirect Rules (the modern Single Redirects / Bulk Redirects products).

Code Meaning (summary)
301 Permanent; clients may change POST to GET when following.
302 Temporary; clients may change POST to GET when following. Default for _redirects when code is omitted.
307 Temporary; original HTTP method should be preserved.
308 Permanent; original HTTP method should be preserved.

301 - Permanent Redirect: The page has permanently moved to a new address. For POST requests, the client or browser might switch the HTTP method to GET when following the redirect.

— Cloudflare, Single Redirects settings

Use 307 or 308 when non-GET methods must survive the redirect (forms, APIs). Use 301 for canonical URL moves (apex ↔ www, path renames). Use 302 when the move is explicitly temporary.

Single Redirects: wildcard, static, and dynamic targets

Section titled “Single Redirects: wildcard, static, and dynamic targets”

Create rules in the dashboard under Create a redirect rule in the dashboard or with Terraform/API (terraform example, API).

Match options:

  • Wildcard pattern — e.g. http*://*.example.com/files/* with target https://example.com/${1}/files/${2}.
  • Custom filter expression — e.g. path equals /contact-us/ → static /contacts/ (example).
  • All incoming requests — rare; use with care.

Redirect types:

  • Static — fixed Location URL.
  • Dynamic — expression computes Location, e.g. concat("https://www.example.com", http.request.uri.path) for apex→www (Manage subdomains).

Turn on Preserve query string when query parameters must survive (documented on most canonical-domain examples). For rules that might affect certificate validation, consider excluding /.well-known/* (Troubleshoot Rules).

Goal Starting point
www → apex (HTTPS, keep path) Redirect from WWW to root
Apex → www Redirect from root to WWW
Whole hostname to another site Redirect requests to a different hostname
Mobile user agent → m. host Perform mobile redirects
Strip locale prefix from path Remove locale from URL path

Bulk Redirects: lists, rules, and matching

Section titled “Bulk Redirects: lists, rules, and matching”

Bulk Redirects are account-level: lists and rules are stored per account (visible in every zone’s UI, but not duplicated per zone). See Create Bulk Redirects in the dashboard and concepts.

Hierarchy:

  1. URL redirect — one row: source_url, target_url, status_code, plus parameters.
  2. Bulk Redirect List — named collection of URL redirects (import CSV or API).
  3. Bulk Redirect Rule — Ruleset Engine rule in phase http_request_redirect that enables a list when its expression matches.

A list does nothing until a Bulk Redirect Rule references it. The same list can back multiple rules. Duplicate source URLs are not allowed inside one list.

Runtime behavior: evaluation happens before the request goes to the origin; after a redirect fires, no further processing runs for that request (How Bulk Redirects work).

WAF interaction: Bulk Redirects run after the WAF. Blocked requests never reach the redirect phase; challenged requests may still log firewall events if they later pass and redirect (Bulk Redirects and the WAF).

Precedence:

  • If the same source URL appears in two lists, the redirect from the first triggering rule in the http_request_redirect ruleset wins (FAQ).
  • Bulk Redirects take precedence over Page Rules redirects (FAQ).
  • On Pages/Workers, account Bulk Redirects run in front of the project’s _redirects file; chains across layers are possible (Surpass redirects limits).

Rule key: use http.request.full_uri or raw.http.request.full_uri consistently in both the rule expression and key; mismatch can match the rule but fail list lookup (Bulk Redirects concepts — Key).

Parameter Default Effect
Subpath matching false Also match paths under the source path (max 16 / in source path when enabled).
Include subdomains false Match apex and subdomains of the source host.
Preserve query string false Append original query to target.
Preserve path suffix true With subpath matching, append unmatched path segments to target.

CSV import defaults: status 301; booleans FALSE unless set to TRUE/true (CSV format). Source URLs in dashboard CSV cannot include a query string (create dashboard).

Quotas (defaults; Enterprise can be higher): per account, up to 15 Bulk Redirect Rules (50 on Enterprise), 5–25 lists, and 10,000–1,000,000 URL redirects depending on plan (Redirects availability).

Page Rules trigger actions when a URL pattern matches. Forwarding URL issues 301 or 302 to a destination URL. Wildcards map to $1, $2, … in the destination (URL forwarding with Page Rules, wildcard matching).

Cloudflare recommends modern Redirect Rules instead: Page Rules are limited (for example 125 rules per zone), harder to debug when several overlap, and URL-only triggers (Page Rules migration guide). Forwarding URL maps to Single Redirects; migration examples cover Always Use HTTPS and Forwarding URL (migration guide).

_redirects on Pages and Workers static assets

Section titled “_redirects on Pages and Workers static assets”

For Cloudflare Pages or Workers static assets, place a plain-text _redirects file in the static output directory (public/ or static/). Format per line:

[source] [destination] [code?]

Limits: 2,000 static + 100 dynamic redirects (2,100 total); 1,000 characters per line. Order matters—first match wins; put static lines before dynamic ones.

Not applied to responses from Pages Functions or Worker code on matching routes; implement redirects in function/Worker code or use account-level Bulk Redirects (Pages redirects caution).

Advanced features in _redirects are limited: no redirect-by-country, cookie, or query-parameter rules in the file itself (advanced redirects table). Redirects run before _headers rules when both match (Redirects and header matching).

When the file cap is exceeded, use Bulk Redirects (Pages limits).

Cloudflare does not offer DNS-level “domain masking”; URL forwarding for sites on the proxy is done with redirect products (DNS FAQ).

  • Grey-cloud or missing DNS — redirect rules never run (Troubleshoot Page Rules — General).
  • Redirect loop — source and target hostname/path point at each other (Page Rules wildcard docs warn about domains forwarding to themselves).
  • Wrong $ capture in Page Rules — only $1 when there is a single *; using $2 breaks forwarding (Troubleshoot Page Rules — General).
  • Expecting _redirects on dynamic routes — Function/Worker responses need code-level redirects.
  • Blocking /.well-known/ or cdn-cgi — breaks DCV and challenges (Troubleshoot Rules).
  • Long redirect chains — update prior redirects to point at the final URL (Redirects — avoid redirect chains).
  • Mixed Page Rules and modern rules — different request views can yield inconsistent results; migrate when possible (Rule phase interactions).
  1. Confirm the hostname has a proxied DNS record in the Cloudflare dashboard (orange cloud).

  2. For a new rule, send a HEAD request and inspect Location and status, as in Add exceptions with Page Rules:

    curl -I https://example.com/old-path
  3. For Bulk Redirects or Single Redirects, open the rule in the dashboard (Bulk redirects, Rules Overview) and confirm list attachment, expression, status code, and preserve-query settings.

  4. After removing or reverting rules, repeat curl -I and confirm you no longer get the old status or Location (Revert configuration).

  5. You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact wording you are asking about.