Skip to content
AI Crawlability Audit

robots.txt for search and AI crawlers: a practical guide

How robots.txt rules are matched under RFC 9309, how to write rules for AI crawlers, and the mistakes that block crawlers by accident.

Reviewed against official sources on · 8 min read

What robots.txt is, and is not

robots.txt is a plain-text file at the root of your site (for example https://www.example.com.au/robots.txt). It tells crawlers which paths they may fetch. Since 2022 it has been formally specified as RFC 9309, the Robots Exclusion Protocol.

It is a request, not a security control. RFC 9309 says the rules are not a form of access authorisation: well-behaved crawlers follow them, but they do not stop anyone from reading a public page. If content must be private, protect it with authentication.

Each scheme, host and port has its own robots.txt. Rules on www.example.com.au do not apply to shop.example.com.au.

How a crawler chooses its rules

Rules are organised into groups that start with one or more User-agent lines. A crawler looks for groups naming its own product token, matched without regard to case. If several groups name it, their rules are combined. Only if no group names it does the crawler use the group for "*".

This catches many people out: a crawler with its own group ignores the "*" group entirely. If you add "User-agent: GPTBot" with one Disallow line, GPTBot no longer follows any of your "*" rules.

User-agent: *
Disallow: /admin/

User-agent: GPTBot
Disallow: /
# GPTBot follows ONLY its own group: it is blocked everywhere.
# Every other crawler follows the * group.

How paths are matched

Rules match from the start of the URL path, including any query string. They are case-sensitive: "Disallow: /Admin" does not block "/admin". The longest matching rule wins, and if an Allow and a Disallow rule are equally long, Allow wins. A "*" matches any sequence of characters, and "$" anchors the end of the URL.

User-agent: *
Disallow: /shop
Allow: /shop/products/
Disallow: /*.pdf$

With these rules, /shop/cart is blocked, /shop/products/chair is allowed (the longer Allow rule wins), and /files/brochure.pdf is blocked, while /files/brochure.pdf?download=1 is not, because "$" requires the URL to end there.

An empty "Disallow:" line blocks nothing. It is a common way to write "allow everything".

What happens when robots.txt is missing or broken

If robots.txt returns a 4xx status such as 404, crawlers treat the site as having no restrictions. That is fine.

If it returns a 5xx server error, or the server cannot be reached, RFC 9309 says crawlers must assume they may fetch nothing. An overloaded server or a firewall that errors on /robots.txt can therefore stop crawlers reaching the whole site.

Crawlers must parse at least the first 500 kibibytes, and may cache the file for up to 24 hours. Changes can take a day to take effect.

Separating AI search from AI training

Several AI providers document separate tokens for search and for model training. OpenAI documents OAI-SearchBot (search) and GPTBot (training). Anthropic documents Claude-SearchBot (search) and ClaudeBot (training). Google documents Google-Extended as a token for Gemini training and grounding that, according to Google, does not affect Google Search.

So you can opt out of training while staying discoverable in AI search:

User-agent: GPTBot
Disallow: /

User-agent: ClaudeBot
Disallow: /

User-agent: Google-Extended
Disallow: /

User-agent: OAI-SearchBot
User-agent: Claude-SearchBot
User-agent: PerplexityBot
Allow: /

User-agent: *
Allow: /

Sitemap: https://www.example.com.au/sitemap.xml

Some user-initiated fetchers may not follow robots.txt. OpenAI says robots.txt rules may not apply to ChatGPT-User, and Perplexity says Perplexity-User generally ignores them, because a person requested the fetch.

Common mistakes we see

  • A staging robots.txt ("Disallow: /") copied to production.
  • Prefixes that are too broad: "Disallow: /s" also blocks /services and /shop.
  • Misspelt directives such as "Disalow". They are ignored.
  • Rules written before any User-agent line. They are ignored.
  • robots.txt served as an HTML error page with status 200, so none of its rules apply.
  • Blocking a page in robots.txt and also adding noindex. The crawler cannot see the noindex, so the URL can still appear in search.

Sources

See how your site handles this

Free, no account needed: which search and AI crawlers your robots.txt allows, and how a few of your pages respond.

Free and no sign-up. It checks your robots.txt, homepage and sitemap and takes about 20–60 seconds. We only read public pages, and our scanner identifies itself and obeys robots.txt.

Want every page checked, with the fixes written out?

The Technical Audit crawls up to 150 pages, checks the documented search and AI crawlers, renders JavaScript and gives you a prioritised fix list for your developer. A$79 one-off, not a subscription.