Question 6

Customer:

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?

Response to Customer:

Hi there,

Thank you for your question!

You are correct that Cloudflare Page Rules do not support conditional redirects based on user-agent strings. However, this can be achieved using Cloudflare Workers, which allow custom JavaScript logic to run on requests at the edge.

Here’s how it works in practice:

This approach gives you full flexibility for conditional redirects based on user-agent, country, path, or other request attributes.

Best regards,
Lejla Vejzović | Cloudflare Support

Thought Process and Tools Used:

Cloudflare Page Rules don’t support conditional redirects based on user-agent headers. To achieve this behavior, I’d recommend using a Cloudflare Worker, where custom logic can inspect request headers and apply redirects dynamically. Specifically, I’d use the Request API to detect the User-Agent header and respond with an appropriate redirect. This approach provides flexibility and operates directly at Cloudflare’s edge, ensuring fast performance and full control over redirection logic.

Back to Home