cloudflare

Setting Up Redirects in Cloudflare: A No-Nonsense Guide for 2025

RC
Redirect Check Team
8 min read
Setting Up Redirects in Cloudflare: A No-Nonsense Guide for 2025

So you need to set up redirects in Cloudflare and you’re staring at the dashboard wondering which of the three different redirect options to use. Been there.

Last month, I helped migrate a client’s entire redirect strategy to Cloudflare. They had 2,000+ redirects scattered across .htaccess files, nginx configs, and three different WordPress plugins. What a mess. But here’s what I learned: Cloudflare’s redirect system is actually pretty brilliant once you understand how it works.

Let me save you the headaches I went through.

The Three Ways to Redirect (And When to Use Each)

Cloudflare gives you three redirect methods, and picking the wrong one will make your life harder. Here’s the real breakdown:

Single Redirects: Your New Best Friend

Single Redirects replaced the old Page Rules for most redirect needs. They’re what you’ll use 80% of the time.

When to use them:

  • Domain-wide redirects (http to https, non-www to www)
  • Pattern-based redirects with wildcards
  • When you need dynamic URL parameters

How to set them up:

  1. Go to your domain in Cloudflare dashboard
  2. Navigate to Rules > Overview
  3. Click “Create rule” > “Redirect Rule”
  4. Pick your matching pattern (wildcard or custom expression)
  5. Set your target URL and status code
  6. Deploy

Here’s a real example I used last week for a client moving from old product URLs to new ones:

Source: http*://example.com/products/old-category/*
Target: https://example.com/shop/new-category/${1}
Status: 301

That ${1} captures everything after the wildcard and preserves it. Saved me from creating hundreds of individual redirects.

Bulk Redirects: When You Have Hundreds

Got a spreadsheet of redirects from your SEO team? This is where Bulk Redirects shine.

When to use them:

  • Migrating from another platform
  • Handling lots of specific URL redirects
  • Managing redirects across multiple domains

The setup process:

  1. Go to Account Home > Bulk Redirects
  2. Create a Bulk Redirect List
  3. Upload your CSV or enter URLs manually
  4. Create a Bulk Redirect Rule to activate them

Pro tip: Test with a small batch first. I once uploaded 5,000 redirects without testing and… well, let’s just say the rollback was painful.

Page Rules: The Legacy Option

Still there, still works, but Cloudflare’s moving away from them. Only use these if you need specific features that aren’t in the newer tools yet.

The Mistakes That Will Ruin Your Day

I’ve made all of these. Learn from my pain.

The Redirect Loop of Death

This one’s a classic. Your Cloudflare SSL setting is “Flexible” but your server redirects HTTP to HTTPS. Result? Infinite loop.

The fix: Set SSL/TLS to “Full” or “Full (strict)” in the Cloudflare dashboard. Match what your origin server expects.

The Orange Cloud Problem

Spent two hours debugging redirects that wouldn’t work. Turns out the DNS record wasn’t proxied (orange cloud off).

Remember: Redirects only work when traffic goes through Cloudflare. That orange cloud needs to be on.

The Wildcard Trap

Tried to redirect example.com/* to www.example.com and lost all my URL paths. Why? Because I forgot to capture and append the wildcard content.

Right way:

Source: example.com/*
Target: www.example.com/${1}

Wrong way:

Source: example.com/*
Target: www.example.com

The Cache Confusion

Changed a redirect but your browser still goes to the old location? That’s your browser being helpful and caching the 301 redirect.

Quick fix: Test in incognito mode or use curl:

curl -I https://example.com/old-url

Real-World Scenarios That Actually Matter

Scenario 1: Moving from HTTP to HTTPS Everywhere

Don’t create individual redirects. Use a Single Redirect with this pattern:

If: SSL/HTTPS is off
Then: Redirect to https://${host}${uri}
Status: 301

One rule, handles everything. Including all your subdomains if you use *.example.com.

Scenario 2: Fixing WordPress Migration Chaos

Just migrated from WordPress? You probably have URLs like /index.php?p=123 that need to go to /blog/actual-post-title.

Use Bulk Redirects for these. Export your old URLs from WordPress, map them to new ones in a spreadsheet, upload to Cloudflare. Done in 10 minutes instead of 10 hours.

Scenario 3: The www vs non-www Decision

Pick one and stick with it. Here’s the Single Redirect for forcing www:

If: Hostname equals "example.com"
Then: Redirect to "https://www.example.com${uri}"
Status: 301

Scenario 4: Country-Specific Redirects Without the Performance Hit

Don’t auto-redirect based on geography. Seriously. It kills performance and annoys users. Instead, show a banner suggesting the local version. But if you must:

If: Country equals "GB"
Then: Redirect to "https://uk.example.com${uri}"
Status: 302  // Use 302 so users can override

Debugging When Things Go Wrong

Things will break. Here’s your troubleshooting checklist:

1. Check DNS First

dig example.com

Is it pointing to Cloudflare? Is it proxied?

2. Test the Redirect Chain

Use our Redirect Check tool or curl to see the full chain:

curl -IL https://example.com/test-url

3. Look for Conflicts

  • Check if multiple rules match the same URL
  • Remember: First matching rule wins
  • Page Rules execute after Single Redirects

4. Check Cloudflare Trace

Enable Trace in your Cloudflare dashboard. It shows exactly which rules are triggering and in what order. This has saved me countless hours.

5. The Nuclear Option

Sometimes you need to start fresh. Export your current rules, disable everything, then add them back one by one. Tedious but effective.

Performance Considerations Nobody Talks About

Every redirect adds latency. On mobile networks, each redirect can add 100-300ms. Here’s how to minimize the impact:

Avoid Redirect Chains

Bad:

http://example.com → https://example.com → https://www.example.com

Good:

http://example.com → https://www.example.com

Use Edge Redirects

Cloudflare processes redirects at their edge servers. That’s faster than your origin server doing it. Move all possible redirects to Cloudflare.

Don’t Redirect Assets

CSS, JS, and image files shouldn’t go through redirects. Update those URLs directly in your code.

The Features You’ll Actually Use

Dynamic URL Variables

Beyond basic wildcards, you can use:

  • ${host} - The hostname
  • ${uri} - The full URI path and query string
  • ${1}, ${2} - Wildcard captures

Preserve Query Strings

Add Preserve query string in your rule settings. Essential for tracking parameters and form submissions.

Exclusion Patterns

Always exclude these paths:

  • /cdn-cgi/* - Cloudflare’s own paths
  • /.well-known/* - Certificate validation
  • /api/* - If your API shouldn’t redirect

Quick Setup Templates

Force HTTPS + www

Rule 1: If SSL is off → Redirect to https://www.example.com${uri}
Rule 2: If Hostname is example.com → Redirect to https://www.example.com${uri}

Remove Trailing Slashes

If: URI Path matches "(.+)/$"
Then: Redirect to https://example.com${1}

Old Domain to New Domain

If: Hostname equals "old-domain.com"
Then: Redirect to https://new-domain.com${uri}
Status: 301

Your Action Plan

  1. Audit your current redirects - List them all, no matter where they live
  2. Choose your method - Single Redirects for patterns, Bulk for specific URLs
  3. Test in staging - Use Cloudflare’s preview mode
  4. Deploy gradually - Start with less critical redirects
  5. Monitor everything - Set up alerts for 404s and redirect loops

The Bottom Line

Cloudflare redirects are powerful but not complicated. Pick the right tool (usually Single Redirects), avoid the common pitfalls, and test everything.

Start simple. Get one redirect working correctly, then build from there. And please, for the love of all that is holy, test your redirects before that big migration on Friday afternoon.

Need to test your Cloudflare redirects? Our Redirect Check tool shows you exactly what’s happening, including redirect chains and response times.

References

  1. [Cloudflare Developers] - Create a redirect rule in the dashboard (2025)
  2. [Cloudflare Developers] - Rules troubleshooting guide (2025)
  3. [Cloudflare Developers] - URL forwarding documentation (2025)
  4. [Cloudflare Community] - Common redirect issues and solutions (Accessed: 2025)

Check your redirects now

Don't let bad redirects hurt your SEO. Use our free tool to audit your links instantly.

#cloudflare#redirects#cdn
Share this article: