/ โ† Redirect Fixes / Cloudflare Redirects
In this guide
  1. Is it Cloudflare or your server?
  2. The places a Cloudflare redirect can come from
  3. The fix, step by step
  4. Example rules
  5. Cloudflare-specific pitfalls
  6. Keeping Cloudflare redirects tidy
  7. Questions and answers

Is it Cloudflare or your server?

Before changing anything, find out which layer is producing the redirect. A response that passes through Cloudflare carries a cf-ray header and usually server: cloudflare, but both appear whether the redirect came from Cloudflare or from your server behind it. The clues that it was Cloudflare itself:

curl -sI http://example.co.uk/old-offer | grep -iE "^HTTP|^location|^server|^cf-ray|^x-"

The Redirect Checker records the status code and Location of every hop, which lets you see whether an edge redirect is followed by a second one from your server. That pattern, one hop from Cloudflare and another from the origin, is the most common chain on Cloudflare sites.

๐Ÿ’ก Cloudflare's dashboard has included a trace tool that shows which rules match a given request. Where it is available on your plan, it is the quickest way to see which rule fired. Menu names and locations change over time, so search the dashboard if you cannot find it where you expect.

The places a Cloudflare redirect can come from

Names and menus change as Cloudflare updates its products, so treat this as a map of what to look for rather than an exact menu path. At the time of writing, a zone can redirect from any of these:

SourceWhat it is good forWhat to watch for
Single redirect rules (shown as Redirect Rules)Pattern-based and site-wide rules: host changes, folder moves, HTTPS, conditions on country or deviceRules run in the order listed, and a match may stop later redirect rules running
Bulk redirectsLong lists of old URL to new URL, such as migrationsLists live at account level and must be switched on by a separate bulk redirect rule
Page Rules (legacy)Older forwarding URL rules on long-standing accountsCloudflare has been moving users away from them; old rules may still be active and forgotten
"Always Use HTTPS" settingUpgrading every http requestRedirects without appearing in any rules list
Workers and similar code featuresLogic that rules cannot express, such as lookups against a data storeCode can redirect on any condition and is easy to overlook in an audit
Pages project _redirects fileSites hosted on Cloudflare PagesLives in the site's code, not the dashboard; write the status on every line

Cloudflare processes these features in a fixed order, documented in its developer documentation. When two of them match the same request, the one that runs first wins and the other may never be seen. That is why an old legacy rule can appear to be ignored, or can quietly override a newer one.

The fix, step by step

Step 1

Confirm Cloudflare is sending the redirect

Run the Redirect Checker on the problem URL and note each hop. Then request it with curl and look at the headers: a redirect with no application cookies, that still happens for a path your server does not have, and that leaves no line in your server access log, came from Cloudflare. If the origin sent it, fix it there instead, using the guide for your server or CMS, and leave Cloudflare alone.

Step 2

List every place that can redirect

Go through the zone and write down every rule or setting that can redirect: single redirect rules, bulk redirect rules and their lists, any legacy page rules with forwarding, the Always Use HTTPS setting, Workers routes, and any Pages _redirects file. Record the match, the target, the status code and whether query strings are kept. Include rules that are switched off, because someone may switch them on again later.

Step 3

Give each job one Cloudflare feature

Decide which feature owns each job and write it at the top of your list. A sensible split is: the HTTPS upgrade in one place only, host and folder patterns in single redirect rules, long one-to-one lists in bulk redirects, and anything needing lookups or complex logic in a Worker. Any legacy forwarding rule should be recreated in the feature that owns its job and then switched off, not left running alongside.

Step 4

Build site-wide rules as single redirects

Create a redirect rule for the host change, for example matching requests where the hostname equals example.co.uk and sending them to https://www.example.co.uk followed by the original path, with a 301 and query strings kept. Use a dynamic target or a wildcard pattern so the path is carried over. Give each rule a clear name, and put more specific rules above general ones so they are reached first.

Step 5

Move one-to-one URL lists into bulk redirects

If you have dozens or hundreds of old addresses each mapped to a new one, put them in a bulk redirect list rather than one rule per URL. Upload them as a CSV with source, target and status, check the options for keeping query strings and matching subpaths, then create the bulk redirect rule that switches the list on. Make sure every target is a final URL, not another redirect source, so the list cannot create chains.

Step 6

Check proxy status and encryption mode

Edge redirects only run for hostnames whose DNS record is proxied, shown as an orange cloud. A redirect-only hostname still needs a proxied record. Then check the SSL/TLS encryption mode: if Cloudflare connects to your server over HTTP while the server forces HTTPS, you get a loop. Install a certificate on the origin and use the full, strict mode so both sides agree the connection is secure.

Step 7

Test, then remove the leftovers

Purge the cache for the affected URLs, then run the Redirect Checker on the four scheme and host combinations and a sample of old URLs from each list. Each should reach a 200 in one hop. Once they do, delete the legacy rules and disabled duplicates you replaced, and remove matching rules from the origin server, so only one layer answers each kind of request in future.

Example rules

The exact field names in the dashboard change from time to time, but the logic is stable. These are written in the form Cloudflare's rule expressions use.

Bare domain to www, keeping the path

When incoming requests match:
  (http.host eq "example.co.uk")
Then:
  Type: Dynamic
  Expression: concat("https://www.example.co.uk", http.request.uri.path)
  Status code: 301
  Preserve query string: on

Old folder to new folder with a wildcard

Request URL:  https://www.example.co.uk/blog/*
Target URL:   https://www.example.co.uk/articles/${1}
Status code:  301
Preserve query string: on

A redirect-only domain

For an old domain that only needs to forward to the main site, add it to Cloudflare, create a proxied DNS record for the bare name and www (Cloudflare's documentation suggests a placeholder address such as 192.0.2.1 for this purpose), then add a single redirect rule sending both hostnames to the matching path on the main domain.

A Worker for logic rules cannot express

export default {
  async fetch(request, env) {
    const url = new URL(request.url);
    const target = await env.REDIRECTS.get(url.pathname);
    if (target) {
      return Response.redirect("https://www.example.co.uk" + target, 301);
    }
    return fetch(request);
  }
};

Here REDIRECTS is a key-value store bound to the Worker. Use this only where rules and bulk lists are not enough: code is harder for the next person to audit.

Cloudflare-specific pitfalls

Deciding between Cloudflare and your origin for each kind of rule is covered in fixing CDN and origin redirect conflicts, and building the list of old and new URLs for a site move is covered in the migration redirects guide.

Keeping Cloudflare redirects tidy

โš ๏ธ Cloudflare changes product names, menus, plan limits and defaults from time to time. Check Cloudflare's own documentation for the current names before following any menu path, including the ones on this page.
Questions and answers

1. Should I use Cloudflare redirect rules or bulk redirects?

Use single redirect rules for patterns and site-wide behaviour: moving a whole host, a whole folder, or anything with conditions. Use bulk redirects for lists of individual old URLs, each mapped to its own new URL, which is typical after a migration. A pattern rule can replace thousands of list entries when the old and new addresses follow the same structure, so check for a pattern before uploading a long list. Many sites end up using both.

2. Are Cloudflare page rules still OK for redirects?

Existing page rules may still work, but Cloudflare has been moving customers to its newer rule features and has published guidance on migrating. Rules left in a legacy feature are easy to forget during audits and can override or duplicate newer rules. The safer course is to recreate each forwarding page rule as a redirect rule or bulk redirect entry, test it, then switch the old page rule off and delete it once you are sure it is not needed.

3. Why is my Cloudflare redirect rule not working?

The most common reasons are that the hostname's DNS record is not proxied, so traffic bypasses Cloudflare; that another feature which runs earlier, such as a legacy rule or a bulk redirect, matches first; that the match expression is slightly wrong, for example missing www or a trailing slash; or that a cached response from the origin is being served. Use the trace tool if your plan has it, and test with curl rather than a browser.

4. Why does Cloudflare cause ERR_TOO_MANY_REDIRECTS?

Usually because the encryption mode is set to flexible, so Cloudflare fetches pages from your server over plain HTTP, while your server or CMS forces HTTPS. The server keeps redirecting a request that the visitor made securely, and the browser gives up. Install a certificate on your server, switch to the full and strict encryption mode, and keep only one HTTPS rule. Conflicting www or slash rules between Cloudflare and the origin can also loop.

5. Can Cloudflare redirect a domain that has no website?

Yes. Add the domain to Cloudflare, create proxied DNS records for the names you want to redirect, and add a redirect rule that sends them to the matching address on your main site. Cloudflare's documentation describes using a placeholder address for the records, since no real server is needed. Remember that visitors who type https will need a certificate for the old domain, which Cloudflare issues for proxied hostnames in most setups.

6. Does a Cloudflare redirect keep the query string?

Only if you tell it to. Single redirect rules and bulk redirect lists each have an option to preserve the query string, and it may not be on by default. If it is off, tracking parameters and search terms in the old URL are dropped. For a dynamic target, you can also build the query string into the expression yourself. Check a test URL with a parameter such as ?utm_source=test in the Redirect Checker after each change.

See which layer answers each hop

The Redirect Checker follows each URL through its full chain, recording every status code, Location header and hop time, and flags long chains, loops, 302s that should be 301s, HTTPS gaps and mixed content.

Open Redirect Fixes โ†’
๐Ÿ’ฌ Got a problem?
Related Guides: All Redirect Fixes  ·  CDN and Origin Redirect Conflicts  ·  Redirect Loops  ·  Security Headers in Cloudflare  ·  Learning Hub

About aiwebpageseo

aiwebpageseo.com is a data-driven SEO and AEO (Answer Engine Optimisation) platform providing a free suite of technical SEO tools. Rather than relying on AI-theorised assumptions, the platform analyses live URL performance, delivering objective diagnostics, page speed metrics, CLS debugging, and site crawl data alongside actionable technical tutorials.