Cloudflare — Forward AI traffic
Cloudflare's Redirect Rules support UA-based matching on every plan,
including free.
Add the rule
- Cloudflare dashboard → your zone → Rules → Redirect Rules → Create rule.
- Configure:
When incoming requests match…
| Field | Operator | Value |
|---|---|---|
User Agent | matches regex | the AI-bot regex (copy from the MCP page card) |
Then…
| Field | Value |
|---|---|
| Type | Static |
| URL | https://oasy.<your-domain> |
| Status code | 302 |
| Preserve query string | Off |
- Deploy.
Verify
Back on the MCP page, click Check forwarding.
Test yourself
curl -I -A "ClaudeBot/1.0" https://your-domain.com/
# → HTTP/2 302
# → location: https://oasy.your-domain.comIf you're on Cloudflare Workers
You can also do this in a Worker — cheaper at high traffic and lets you
add custom logging:
const BOTS = /ChatGPT-User|PerplexityBot|GPTBot|ClaudeBot|.../i;
export default {
async fetch(request, env) {
const ua = request.headers.get('user-agent') ?? '';
if (BOTS.test(ua)) {
return Response.redirect(`https://oasy.${env.DOMAIN}`, 302);
}
return fetch(request);
},
};Add the Worker route to your-domain.com/* and you're done.
Common gotchas
- "Bot Fight Mode" can interfere — Cloudflare may serve a challenge to
some AI UAs before your Redirect Rule fires. Either whitelist the bots
there or move this rule to a Worker (above) which runs first. - AMP / mobile redirects — if you already have other Redirect Rules,
order matters. Put this one above any rules that strip query strings
or rewrite hostnames.