Managing Redirects with Cloudflare
Guide to Cloudflare redirect rules: Page Rules, Bulk Redirects, and Transform Rules. How to set them up, common pitfalls including the ERR_TOO_MANY_REDIRECTS error from SSL/TLS mode mismatch, and when to use each.
Cloudflare sits between your users and your server. That position makes it the ideal place to handle redirects — the redirect happens at the edge, before the request ever reaches your origin. Faster for users, less load on your server.
But Cloudflare offers multiple ways to redirect, and picking the wrong one (or misconfiguring the right one) leads to redirect loops, broken URLs, and the dreaded ERR_TOO_MANY_REDIRECTS. Here is how to do it correctly.
Cloudflare Redirect Options
Cloudflare provides three mechanisms for redirects, each with different strengths:
| Feature | Page Rules | Bulk Redirects | Transform Rules |
|---|---|---|---|
| Redirect type | 301 or 302 | 301 or 302 | Rewrite (no redirect) |
| URL matching | Wildcard patterns | Exact URL or prefix | Regex + wildcard |
| Wildcard capture | Yes ($1, $2) | No | Yes (regex groups) |
| Free tier limit | 3 rules | 20 lists, 20k URLs total | 10 rules |
| Best for | Pattern-based redirects | Large redirect maps | URL rewrites (not redirects) |
| Status | Being deprecated | Current recommendation | Current |
Page Rules are being phased out
Cloudflare is deprecating Page Rules in favor of newer rules (Redirect Rules, which are part of the Rules product). If you are setting up new redirects, use Bulk Redirects or the newer Redirect Rules. Migrate existing Page Rules when possible.
Setting Up Bulk Redirects
Bulk Redirects are Cloudflare's recommended approach for most redirect scenarios. They handle large lists of URL-to-URL mappings without consuming Page Rules.
Create a Bulk Redirect List
Go to Account Home > Bulk Redirects > Create Bulk Redirect List. Give the list a descriptive name (e.g., "2024 migration redirects" or "legacy blog redirects").
Add redirect entries
Add each redirect as a source URL and target URL pair. Choose 301 (permanent) or 302 (temporary) for each entry. You can add entries manually or import a CSV.
Configure matching options
For each entry, decide:
- Include subpath matching: If enabled,
/old-path/anythingmatches. If disabled, only/old-pathexactly matches. - Preserve query string: Whether to pass query parameters through to the target URL.
- Preserve path suffix: Whether to append the matched subpath to the target URL.
Create a Bulk Redirect Rule to enable the list
Go to Account Home > Bulk Redirects > Create Bulk Redirect Rule. Select the list you created. Enable the rule. Bulk Redirect Lists do nothing until they are attached to an enabled rule.
Test your redirects
After enabling, test each redirect. Use cURL or a redirect checker to verify the correct status code and destination. Do not assume it works because you configured it — verify.
CSV import for large lists
For migrations with hundreds of redirects, prepare a CSV file with columns for source URL, target URL, and status code. Import it directly into a Bulk Redirect List instead of adding entries one by one.
Setting Up Page Rules (Legacy)
Page Rules are simpler but limited. Each rule matches a URL pattern and performs an action — in this case, a forwarding URL redirect.
Navigate to Page Rules
Go to your domain in Cloudflare > Rules > Page Rules > Create Page Rule.
Enter the URL pattern
Use Cloudflare's wildcard syntax. * matches any characters. Example: example.com/old-blog/* matches any URL under /old-blog/.
Set the action to Forwarding URL
Choose Forwarding URL from the action dropdown. Select 301 (permanent) or 302 (temporary). Enter the destination URL. Use $1, $2 to reference wildcard captures.
Example: Pattern example.com/old-blog/* with destination https://example.com/articles/$1 redirects /old-blog/my-post to /articles/my-post.
Save and deploy
Save the rule. Page Rules take effect within a few seconds. Test immediately.
Page Rule limits: The free plan includes 3 Page Rules. Pro gets 20. Business gets 50. Enterprise gets 125. For more than a handful of redirects, use Bulk Redirects instead.
The ERR_TOO_MANY_REDIRECTS Problem
This is the single most common Cloudflare issue. You set up Cloudflare, and suddenly your site shows ERR_TOO_MANY_REDIRECTS. The cause is almost always the SSL/TLS encryption mode.
What Happens
- Your site is configured for HTTPS
- Cloudflare's SSL/TLS mode is set to Flexible
- Cloudflare connects to your origin server over HTTP (because Flexible mode does not use HTTPS to the origin)
- Your origin server has an HTTP-to-HTTPS redirect
- Your origin redirects Cloudflare back to HTTPS
- Cloudflare sees the HTTPS request, connects to origin over HTTP again (Flexible mode)
- Origin redirects to HTTPS again
- Infinite loop
The Fix
Check your SSL/TLS mode
Go to your domain in Cloudflare > SSL/TLS > Overview. Check the current mode.
Set the mode to Full (Strict)
If your origin server has a valid SSL certificate (including free ones from Let's Encrypt), set the mode to Full (Strict). This tells Cloudflare to connect to your origin over HTTPS and validate the certificate.
If your origin has a self-signed certificate, use Full (without Strict). But get a real certificate — self-signed certificates are a liability.
Remove redundant redirect rules
If you added Cloudflare Page Rules to force HTTPS, and your origin also forces HTTPS, you have duplicate redirect logic. Choose one place to handle the HTTP-to-HTTPS redirect. Cloudflare's "Always Use HTTPS" setting under SSL/TLS > Edge Certificates is the simplest option.
Flexible mode is almost never correct
Flexible SSL mode means Cloudflare decrypts HTTPS from the user but connects to your server over plain HTTP. This is insecure and is the number one cause of redirect loops. Use Full (Strict) unless you have a specific reason not to. If your origin does not support HTTPS, fix that first.
Trace your redirect chains
Find redirect loops, broken chains, and unnecessary hops instantly.
Other Common Cloudflare Redirect Pitfalls
Conflicting Rules
Multiple Cloudflare rules can match the same URL. Page Rules execute in order (top to bottom, first match wins). Bulk Redirects have lower priority than Page Rules. If both match, the Page Rule wins — which may not be what you expect.
Fix: Audit your rules for overlaps. Use the Cloudflare dashboard's trace tool or test with cURL to see which rule fires for a given URL.
WWW vs Non-WWW Loops
You set up a redirect from www.example.com to example.com, but your origin redirects example.com back to www.example.com. Loop.
Fix: Decide on one canonical form (www or non-www). Configure it consistently in both Cloudflare and your origin server. Do not let them disagree.
Query String Handling
By default, some Cloudflare redirect methods strip query strings. If your redirects need to pass ?utm_source=... or other parameters through, explicitly enable query string preservation in your redirect configuration.
Cached Redirects
Cloudflare may cache redirect responses. If you change a redirect rule but the old redirect still fires, purge the Cloudflare cache for that URL. Go to Caching > Configuration > Purge Cache and enter the specific URL.
When to Use Each Cloudflare Redirect Method
Use Bulk Redirects when:
- You have a list of specific URL-to-URL mappings
- You are migrating a site and have a redirect map
- You need more than 3 redirects on the free plan
- You want simple prefix or exact-match redirects
Use Page Rules (or Redirect Rules) when:
- You need wildcard capture groups ($1, $2) in the destination
- You have pattern-based redirects (e.g., entire path prefixes)
- You need to combine a redirect with other Cloudflare settings
Use Transform Rules when:
- You need to rewrite URLs without a visible redirect (internal rewrite)
- You want to modify headers or query strings without changing the URL the user sees
- This is not a redirect — it is a rewrite. Different thing.
Debugging Cloudflare Redirects
When a Cloudflare redirect is not working as expected:
- Check with cURL:
curl -sIL "https://example.com/old-url"shows every hop. Look at theserverheader — if it sayscloudflare, the redirect is from Cloudflare. If not, it is from your origin. - Check rule priority: Page Rules execute before Bulk Redirects. A Page Rule might be intercepting the request before your Bulk Redirect fires.
- Check DNS: Make sure the domain is proxied through Cloudflare (orange cloud, not gray). Cloudflare rules only apply to proxied traffic.
- Purge cache: If you changed a rule and it is not taking effect, purge the cache for that specific URL.
- Check SSL/TLS mode: If you see a loop, this is almost certainly the issue. Set it to Full (Strict).
Cloudflare redirect debugging checklist
- Verify SSL/TLS mode is Full (Strict)
- Confirm the domain DNS record is proxied (orange cloud)
- Check for conflicting Page Rules and Bulk Redirects
- Test with cURL to see all hops and headers
- Purge cache if rules were recently changed
- Verify origin server is not adding conflicting redirects
- Check that "Always Use HTTPS" is not conflicting with origin HTTPS redirects
Related Articles
Cloudflare makes redirects fast. Misconfigured Cloudflare makes redirects infinite. Know the difference.
Never miss a broken redirect
Trace redirect chains and detect issues before they affect your users and SEO. Free instant tracing.