Skip to content

Cloudflare Redirect Rules: bulk lists vs dynamic expression-driven

When to use Single (dynamic, expression-based) Redirect Rules vs Bulk Redirects (lists with priority). Status codes, query/path preservation, common loops, and how to migrate from a .htaccess.

A WordPress site is being replatformed onto a Pages project. The old site has 4,200 individual redirects in .htaccess from a decade of slug renames, plus a pattern that should send every /blog/category/* to /topics/$1. Cloudflare offers two tools: Single Redirects with full expression filters, and Bulk Redirects for long literal lists. They overlap in capability but not in cost or maintainability. This article is the decision and the migration.

How to verify

List the redirect rules already on a zone, and the Bulk Redirect lists at the account level (lists are account-scoped and attached to zones via a list reference):

# Single (dynamic) Redirect Rules at the zone level
curl -s -H "Authorization: Bearer $CF_API_TOKEN" \
  "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/rulesets" \
  | jq '.result[] | select(.phase == "http_request_dynamic_redirect")'

# Bulk Redirect lists at the account level
curl -s -H "Authorization: Bearer $CF_API_TOKEN" \
  "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/rules/lists?kind=redirect" | jq

# Curl a known-redirected path to see the chain
curl -sIL "https://example.com/old-slug" | grep -iE 'HTTP|location'

The cf-ray header on the redirect response confirms Cloudflare emitted it (rather than the origin), and the Location header shows the resolved target.

What’s happening

Both Redirect Rule types live in the same phase of the pipeline — http_request_dynamic_redirect — and fire before Cache Rules, Configuration Rules, and Origin Rules. They differ in how the source-to-target relationship is expressed. A Single Redirect uses a filter expression and a (static or dynamic) target — one rule per pattern. A Bulk Redirect uses a Redirect List, where each row is a literal source-url → target-url mapping with a status code and a couple of flags — one entry per URL.

Do you have a patternor a long flat list?patternflat listSingle Redirectexpression filterdynamic target/blog/* → /topics/$1limit: few hundred rules / zoneBulk RedirectsRedirect List rowsliteral source → target4,200 entries OKlimit: thousands per list
Patterns go to Single Redirects; long flat one-to-one lists go to Bulk Redirects.

The practical rule of thumb: if you would write a regex or a wildcard, use Single Redirects. If you have a flat CSV of source URLs and target URLs that don’t share structure (the kind of list a CMS migration produces), use Bulk Redirects. Mixing the two is fine — Bulk Redirects evaluate alongside Single Redirects in the same phase, with priorities determined by rule order and list priority within a list.

Decision

The shape of the redirect set tells you which to pick.

  1. Pick Single Redirects when there’s a pattern. A Single Redirect is one expression and one target. Example: every /blog/category/<anything> should go to /topics/<anything> with a 301:

    When: (http.host eq "example.com"
           and starts_with(http.request.uri.path, "/blog/category/"))
    Then: Redirect to...
      Target → Dynamic → concat("https://example.com/topics/",
                                substring(http.request.uri.path, 16))
      Status code → 301
      Preserve query string → on

    The 16 is the length of /blog/category/. The dynamic target language supports concat, substring, regex_replace, lower, upper. The expression supports the same operators as the WAF — eq, starts_with, ends_with, matches (regex), in, and boolean compounds.

  2. Pick Bulk Redirects when there’s a long flat list. Bulk Redirects use a Redirect List — a CSV upload (or API push) where each row is source_url,target_url,status_code,preserve_query_string,preserve_path_suffix,include_subdomains,subpath_matching. The list is stored at the account level; zones reference it via a redirect ruleset that includes the list. Example list:

    https://example.com/2018/old-product, https://example.com/products/new, 301, true, false, false, false
    https://example.com/2019/sunsetted,   https://example.com/, 302, false, false, false, false
    https://example.com/forum,            https://community.example.com, 301, true, false, false, false

    Limits matter: a single list can hold thousands of entries (the exact limit varies by plan; Free zones get a smaller list, Enterprise gets the largest). Multiple lists can attach to one zone for namespacing — one list for marketing, one for legal pages, one for the migration cohort.

  3. Choose the status code deliberately. 301 (permanent) is what you want for content moves — search engines transfer ranking to the new URL. 302 (temporary) is for A/B tests or maintenance windows where the redirect should not be cached forever. 307/308 preserve the request method (a POST to /old becomes a POST to /new) — only relevant for API endpoints, never for browser navigation. Default to 301 and only deviate with a reason.

  4. Preserve path and query string by default. Both rule types have toggles. For a content move, preserve_query_string: true is almost always right (campaign tracking, analytics, search params should survive). preserve_path_suffix on a Bulk Redirect treats the source as a prefix — /blog → /articles with the toggle on means /blog/2024/post becomes /articles/2024/post automatically. With the toggle off, only the exact source URL redirects.

  5. For .htaccess migrations, run a one-time conversion. A common shape in WordPress .htaccess:

    Redirect 301 /old-slug /new-slug
    RedirectMatch 301 ^/blog/(.*)$ /articles/$1

    The first form is a Bulk Redirect candidate (one row per directive). The second is a Single Redirect (one rule, regex-backed). A short shell script can split a .htaccess into a CSV plus a list of regex patterns:

    # Extract literal Redirect 301 lines → CSV for Bulk Redirects
    grep -E '^Redirect 301 ' .htaccess \
      | awk '{print "https://example.com"$3",https://example.com"$4",301,true,false,false,false"}' \
      > bulk-redirects.csv
    
    # RedirectMatch lines → review by hand, convert to Single Redirects
    grep -E '^RedirectMatch' .htaccess

    Push the CSV to a Redirect List, attach it to the zone, and write the handful of Single Redirects manually. Verify with curl -sIL against a sample of 20 URLs from each bucket before flipping DNS.

.htaccessRedirect 301 /a /bRedirectMatch ^/x/(.*)$Literal linesgrep / awk → CSVRegex linesmanual reviewBulk RedirectsRedirect ListSingle Redirectsexpression-basedSplit the .htaccess two ways, push the CSV, hand-write the handful of patterns.
.htaccess migrations split cleanly into a Bulk list (literals) and a small set of Single Redirects (patterns).

Common pitfalls

  • Redirect loops happen when the target also matches the source filter. A rule that sends /old/* to /old/new/foo will loop because the target also starts with /old/. Either tighten the filter (http.request.uri.path eq "/old/foo") or make the target a different path entirely.
  • Bulk Redirect priority is by list order, not list age. If two lists attached to a zone both contain the same source URL, the list with the lower priority number wins. Audit list priorities when adding a new list.
  • A 302 is treated as cacheable by some clients. If the redirect must be revisited daily (A/B test reassignment), use 302 and set Cache-Control: no-store via a Response Header Modification rule on the redirect responses.
  • Preserving path suffix is off by default in Bulk Redirects. A row of /blog → /articles without the toggle redirects exactly /blog, not /blog/anything. The default surprises people moving from .htaccess Redirect 301, which has prefix-matching behaviour.
  • Subdomain redirects need include_subdomains. A row for https://example.com/old won’t fire on https://www.example.com/old unless the flag is on. For wildcard hostnames, use a Single Redirect with http.host matches "^(www\\.)?example\\.com$".

In our engagements, the long tail of CMS-migration redirects always lives in a Bulk Redirect list — it’s the layer marketing can audit without engineering, and it scales without rule-count pressure. Pattern redirects stay in Single Redirects so the expression sits next to the cache and origin rules that share the same filter language. Stack Harbor owns the Cloudflare edge configuration end to end as part of managed operations.