Customer inquire: I want to redirect visitor with specific user agent (e.g., MSIE 8.0) to a different page. It seems this is not possible with Cloudflare Page Rules. Is there any other way to achieve that using Cloudflare?
Hello,
Thank you for reaching out to Cloudflare support.
I understand that you want to redirect visitors with a specific user agent (such as MSIE 8.0) to a different page. While this is not directly possible with Cloudflare Page Rules, you can achieve this by using Cloudflare Workers.
Cloudflare Workers allow you to run JavaScript on the edge and inspect request headers, making it possible to perform actions such as redirection based on the user agent. Here’s how you can set this up:
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
const userAgent = request.headers.get('User-Agent') || ''
if (userAgent.includes('MSIE 8.0')) {
return Response.redirect('https://example.com/ie8', 302)
}
return fetch(request)
}
By following these steps, you can effectively redirect users based on their user agent using Cloudflare Workers. If you have any further questions or need assistance with this process, please don't hesitate to contact us.
Best regards,
Saber Moahmed
Cloudflare Support Team