Redirects for AI Training
Redirects for AI Training enforces your existing <link rel="canonical"> tags as 301 redirects for verified AI training crawlers. When a verified bot with the AI Crawler category requests a page whose canonical tag points to a different same-origin URL, Cloudflare returns a 301 Moved Permanently to the canonical. All other visitors—browsers, search engines, AI Assistants—receive the original page unchanged.
To learn more about why this feature can be useful, refer to the announcement blog post ↗.
Redirects for AI Training is available as a toggle in AI Crawl Control > Quick Actions, alongside Markdown for Agents and Managed robots.txt.
To enable Redirects for AI Training for your zone in the dashboard:
- Log into the Cloudflare dashboard ↗ and select your account (you need a Pro or Business plan).
- Select the zone you want to configure.
- Visit the AI Crawl Control ↗ section.
- Enable Redirects for AI Training.
To enable Redirects for AI Training for specific subdomains or paths instead of your entire zone, create a configuration rule:
- Log in to the Cloudflare dashboard ↗ and select your account.
- Select the zone you want to configure.
- Go to Rules > Overview and select Create rule > Configuration Rules.
- Under When incoming requests match, build an expression to match your subdomain (for example,
http.host eq "docs.example.com") or path. - Under Then the settings are, select Add setting > Redirects for AI Training and set it to On.
- Select Deploy.
To enable Redirects for AI Training for your zone using APIs, send a PATCH to /client/v4/zones/{zone_tag}/settings/redirects_for_ai_training with the payload {"value": "on"} to the Cloudflare API.
You will need to create an API token with the Zone Settings edit permissions enabled.
Example:
curl -X PATCH 'https://api.cloudflare.com/client/v4/zones/{zone_tag}/settings/redirects_for_ai_training' \ --header 'Content-Type: application/json' \ --header "Authorization: Bearer {api_token}" --data-raw '{"value": "on"}'To enable Redirects for AI Training for specific subdomains or paths instead of your entire zone, create a configuration rule:
curl --request PUT \ --url "https://api.cloudflare.com/client/v4/zones/{zone_id}/rulesets/phases/http_config_settings/entrypoint" \ --header "Authorization: Bearer {api_token}" \ --header "Content-Type: application/json" \ --data '{ "rules": [{ "expression": "http.host eq \"docs.example.com\"", "action": "set_config", "action_parameters": { "redirects_for_ai_training": true }, "description": "Enable Redirects for AI Training for docs subdomain" }] }'You can also use path-based expressions like starts_with(http.request.uri.path, "/docs/"). For more information on building expressions, refer to Rules language.
If you are using Cloudflare for SaaS and want to enable Redirects for AI Training for your custom hostnames, you have two options:
To enable Redirects for AI Training for all custom hostnames on your SaaS zone:
- Log into the Cloudflare dashboard ↗ and select your account.
- Select your SaaS zone.
- Look for Quick Actions.
- Toggle the Redirects for AI Training button to enable.
Enabling Redirects for AI Training for specific custom hostnames requires an advanced subscription with access to custom metadata.
When creating or updating a custom hostname via API, add redirects_for_ai_training to the custom_metadata object:
curl --request PATCH \ --url "https://api.cloudflare.com/client/v4/zones/{zone_id}/custom_hostnames/{custom_hostname_id}" \ --header "Authorization: Bearer {api_token}" \ --header "Content-Type: application/json" \ --data '{ "custom_metadata": { "redirects_for_ai_training": "enabled" } }'Create a Configuration Rule on your SaaS zone that matches custom hostnames with the metadata and enables the feature:
curl --request PUT \ --url "https://api.cloudflare.com/client/v4/zones/{zone_id}/rulesets/phases/http_config_settings/entrypoint" \ --header "Authorization: Bearer {api_token}" \ --header "Content-Type: application/json" \ --data '{ "rules": [{ "expression": "lookup_json_string(cf.hostname.metadata, \"redirects_for_ai_training\") eq \"enabled\"", "action": "set_config", "action_parameters": { "redirects_for_ai_training": true }, "description": "Enable Redirects for AI Training for opted-in custom hostnames" }] }'This will enable the feature on custom hostnames that have the redirects_for_ai_training custom metadata tag set.
Cloudflare inspects the origin HTML response to verified AI training crawlers and:
- Stream-parses the
<head>of the origin response to extract<link rel="canonical" href="..."> - Resolves relative canonical URLs against the request URL
- Validates that the canonical URL is same-origin and differs from the current URL
- Returns a
301redirect to the canonical URL
If no canonical tag is found, the canonical is cross-origin, or the page is self-canonical, the origin response passes through unchanged.
The feature parses the <link rel="canonical"> tag from the <head> section of the origin response:
<!DOCTYPE html><html><head> <link rel="canonical" href="https://example.com/current-version"></head><body> <!-- Page content --></body></html>Both absolute and relative URLs are supported:
<!-- Absolute URL --><link rel="canonical" href="https://example.com/page">
<!-- Relative URL (resolved against request URL) --><link rel="canonical" href="/current-page">Redirects for AI Training operates at a different layer than Single Redirects and Bulk Redirects. Those redirect rules execute before the origin is contacted. Redirects for AI Training executes after the origin responds, because it needs to read the canonical tag from the origin HTML.
If a Single Redirect or Bulk Redirect matches first, the request is redirected before Redirects for AI Training has a chance to evaluate it.
Available on Pro, Business, and Enterprise plans at no additional cost.
- Only HTML responses (
content-type: text/html) from the origin are evaluated. Other content types pass through unchanged. - The canonical tag must appear within the first 256 KB of the uncompressed HTML response body.
- Only same-origin canonical URLs trigger a redirect. Cross-origin canonicals are ignored.
- Only verified bots with the AI Crawler category are redirected. AI Assistants and AI Search bots are not affected.
- Self-canonical pages (where the canonical URL matches the request URL) are not redirected.
- Best-effort loop detection uses the
Refererheader. If a crawler was just redirected from the canonical URL back to the current page, the origin HTML is served instead of redirecting. This handles common two-page canonical misconfigurations (Page A canonical points to Page B, Page B canonical points to Page A).
When a redirect is issued, Cloudflare logs the canonical target URL in your HTTP request logs via the redirects_for_ai_training_target field. You can use the GraphQL Analytics API or Logpush to query this data.
- Manage AI crawlers - Set allow or block rules per crawler
- Analyze AI traffic - View request metrics by crawler, operator, and content type
- Markdown for Agents - Serve HTML as markdown via content negotiation
- Content Signals Policy ↗ - Signal post-access content usage preferences in
robots.txt - Directives - Monitor
robots.txtcompliance and check Agent Readiness - Single Redirects - Rule-based URL redirects that execute before origin
- Verified bots - Bot categories including AI Crawler, AI Assistant, and AI Search