Question 6

Subject: Redirection based on user agent

Customer Query: 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?

Response

Hi there,

Great question and you're right: Page Rules don't support redirects based on user agents (like MSIE 8.0). But not to worry — Cloudflare has some more powerful tools that can help.

Here are a few options:

  • Cloudflare Workers (Recommended)
    This is the most flexible and scalable solution. With Workers, you can write a small script that checks the user agent and redirects users based on exactly what you need.
    Here's a helpful example:
    🔗 User-Agent Based Redirect with Workers
  • Transform Rules (Enterprise only)
    If you're on an Enterprise plan, Transform Rules let you modify requests and responses, including based on the user agent, before they reach your origin.
  • Firewall Rules
    While not meant specifically for redirection, Firewall Rules can detect specific user agents and take actions like blocking or issuing a JavaScript challenge. For basic handling, this might be enough.

If you'd like, I can help you set up a custom Worker script for this use case. Just let me know what user agents you'd like to target and where you'd like to redirect them, and I'll provide a tailored code snippet.

Looking forward to helping you get this in place!

Best regards,
Aviv
Cloudflare Support

Thought Process

This question requires knowledge of Cloudflare's various ways to handle conditional redirects. The customer is correct that Page Rules can't do user-agent based redirects, so I need to provide alternative solutions.

Tools I would recommend:

  • Cloudflare Workers: The most flexible solution for this specific use case
  • Cloudflare Documentation: For examples and implementation guides
  • User Agent Testing Tools: To verify the redirect works correctly

My approach is to acknowledge the limitation of Page Rules while offering multiple alternative solutions. I've prioritized the options from most flexible (Workers) to more limited but potentially simpler options. I've also offered to provide a custom solution, which shows proactive support and builds customer confidence.

Back to Questions