← Back to Noble Demos Open Redirect Rules in Dashboard ↗

~/redirect-rules

// Master HTTP redirects — status codes, patterns, conditional routing, live trace

Query String Handling

Preserve, strip, or transform query parameters with dynamic expressions.

🔗 Real-world: Clean URLs for SEO

Your old site used /product?id=123. Your new site wants clean URLs like /products/123. Cloudflare Redirect Rules can extract query parameters and inject them into the path — giving you SEO-friendly URLs without breaking old bookmarks or inbound links.

Preserve Query String

/product?id=123/products?id=123

Expression: concat("/products", http.request.uri.query)

Strip Query String

/old-clean?utm_source=x/clean

Expression: "/clean" (no .query reference)

Extract Query to Path

/item?id=456/items/456

Uses regex_replace() to pull id from query into path

Drop Tracking Params Only

Keep useful params, strip UTM

Uses regex_replace() to remove only utm_* parameters
💡 Key Dynamic Expressions:
  • http.request.uri — Full URI including query string
  • http.request.uri.path — Path only, no query
  • http.request.uri.query — Query string only (includes leading ?)
  • concat(a, b, c) — Join strings together
  • regex_replace(input, pattern, replacement) — Transform with regex capture groups

Hostname & Path Patterns

Classic redirect scenarios: HTTPS enforcement, WWW canonicalization, path rewrites.

🔗 Real-world: Company rebrand

A company rebrand moved blog.oldcorp.com/post/123 to newcorp.com/blog/article/123. Thousands of inbound links depend on the old URLs. One wildcard redirect preserves every one of them.

Force HTTPS

Redirect http:// to https://

Zone rule active: Try visiting http://redirect-rules.nobledemos.com/

WWW Canonicalization

www.redirect-rulesredirect-rules

Zone rule active: Strips www subdomain, preserves path

Path Prefix Wildcard

/old-blog/*/blog/*

Exact Path

/contact/about/contact

Conditional Redirects

Route users based on country, device, or language preference.

🌍 Real-world: E-commerce localization

Visitors from Germany land on /de automatically. Without edge redirects, you ship a 400kb JS bundle that reads navigator.language and client-side redirects — 2 seconds slower, bad for SEO, bad for Core Web Vitals.

Country-Based Routing

Redirect based on cf.country (edge-computed)

Zone rules active: FR → /fr, DE → /de
Visit the homepage from France or Germany to see the redirect. Check the dashboard to see the rule configuration.

Bot / Crawler Routing

Googlebot & Bingbot on //bot-welcome

Zone rule active: matches http.user_agent contains "Googlebot"

Browsers can't spoof User-Agent, so test with curl:

curl -sI -A "Googlebot" https://redirect-rules.nobledemos.com/ | grep -i location

Live Test (Worker proxy)

Simulate a bot request from the browser

Worker fetches the homepage with a spoofed UA and returns the response
Click to test

Live Trace

Follow redirect chains with real fetch({redirect: 'manual'}) calls.

🔍 Real-world: Debug slow page loads

Users complaining your site is slow? They might be hitting a 4-hop redirect chain: httphttps, www → root, /old/new, then the final page. Each hop is a full round trip. Trace it and collapse them into one.

Enter a URL above to trace its redirect chain.