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?
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:
User-Agent header of incoming requests.MSIE 8.0 (or any other string you want), respond with a 301 or 302 redirect to your target page.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
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.