Question 6 of 6

Redirection based on user agent

Customer ticket

Subject: Redirection based on user agent

I want to redirect visitor with specific user agent (*MSIE 8.0* for example) to a different page. It seems this is not possible with Cloudflare Page Rules. Is there any other way to achieve that using Cloudflare?

2. Thought process

The customer has correctly found that Page Rules can’t do this. Page Rules only match URL patterns, and they are now marked as deprecated. So I confirm that first, then offer the simplest correct tool followed by a more powerful fallback:

  • Single Redirects support custom filter expressions on any request field, including http.user_agent. I checked availability and quotas in the current docs: available on all plans (Free 10, Pro 25, Business 50, Enterprise 300 rules) with regex on Business and above, so I can recommend it with confidence even on Free.
  • Pitfalls I anticipated: redirect loops (exclude the target path), 301 caching in browsers (use 302 for client-dependent redirects), the proxied-record requirement, and the customer’s *MSIE 8.0* glob syntax (with contains the wildcards are unnecessary).
  • Workers for anything beyond a simple match. I included complete, deployable code with routes, because the role is Developer Platform focused and customers like this often grow into Workers. I also mention Snippets (Pro+) as a middle ground and point out the cost trade-off.
  • Verification: a curl -A test lets the customer prove the behaviour without finding an IE8 machine.

3. Tools I would use, and why

ToolWhy
Dashboard: Rules > Redirect RulesNative, no-code way to redirect on the User-Agent, on every plan.
Rules language docs (http.user_agent, contains, matches)Confirm field names, operator semantics and plan-gated regex support.
curl -sI -A "…MSIE 8.0…"Simulate an IE8 visitor and confirm the 302 and Location header; compare with a normal user agent.
Cloudflare Trace (Rules > Trace)Check which rule matches a request with a given User-Agent.
Wrangler (npx wrangler deploy / tail)Deploy the Worker alternative with routes, then watch live requests to confirm it fires.
Workers Playground / dashboard editorQuickly prototype and test the Worker logic before attaching routes.