Blog · SEO

Robots.txt: How It Works, Examples and How to Test It

robots.txt decides which URLs crawlers may fetch, and one wrong line can hide a whole site. This guide explains how Google and RFC 9309 read the file, what each status code does, copy-ready examples, the robots.txt vs noindex trap, and how to fix every problem a robots.txt checker reports.

Searvia · 10/24/2026 · 14 min read

In short: robots.txt is a plain text file at /robots.txt that tells crawlers which URLs they may fetch. Rules are grouped by User-agent; a crawler uses the group that names it, or the * group if none does, and the longest matching Allow or Disallow path wins. It controls crawling, not indexing: to keep a page out of Google, use noindex. A 404 means "crawl everything", a 5xx means "stop". Most damage comes from one line, Disallow: /, left over from a staging site.

robots.txt is the shortest file on most websites and the one with the largest blast radius. A single Disallow: / under User-agent: * hides the whole site from Google, Bing, Apple and every AI search crawler. A missing slash, a rule in the wrong group or a server error on the file itself can do nearly as much damage, and nothing on the visible site looks broken.

This guide covers how crawlers read the file according to RFC 9309 and Google's specification, copy-ready examples, how our free robots.txt checker tests your file, and how to fix every problem it reports.

What robots.txt does, and what it doesn't

Google's introduction puts it plainly: a robots.txt file "tells search engine crawlers which URLs the crawler can access on your site," and its main job is managing crawler traffic. It is "not a mechanism for keeping a web page out of Google." A disallowed URL "might still" be indexed "if it is linked from other places on the web," typically shown without a description.

Three more limits from the same sources:

The syntax

A robots.txt file is a list of groups. Each group starts with one or more User-agent lines followed by Allow and Disallow rules. Sitemap lines can appear anywhere.

# Comments start with a hash
User-agent: Googlebot
User-agent: Bingbot
Disallow: /cart/
Disallow: /search
Allow: /search/help

User-agent: *
Disallow: /admin/

Sitemap: https://www.example.com/sitemap.xml
FieldSupported by GoogleWhat it does
user-agentYesNames the crawler the group applies to; * means all others
disallowYesA path prefix the crawler should not fetch; empty means nothing is disallowed
allowYesA path prefix the crawler may fetch, used to make exceptions
sitemapYesThe absolute URL of a sitemap; not tied to any group
crawl-delayNoIgnored by Google; read by some other crawlers, such as Anthropic's
noindex and anything elseNoIgnored

Field names are case-insensitive; paths are case-sensitive, so Disallow: /Admin/ does not block /admin/. Two special characters are supported: * matches any sequence of characters, and $ marks the end of the URL. Disallow: /*.pdf$ blocks every URL ending in .pdf; Disallow: /*? blocks every URL with a query string.

Which group applies to a crawler

This is the rule people get wrong most often. Per Google, "only one group is valid for a particular crawler": the group with the most specific matching user agent. Groups that name the same agent are merged, but a named group is not combined with the * group. RFC 9309 says the same: crawlers match their product token case-insensitively, combine matching groups, and fall back to * only "if no matching group exists."

So in the file above, Googlebot follows only its own group. It may crawl /admin/, because the * group does not apply to it. If a rule should apply to everyone, repeat it in each named group.

Two crawler-specific details are worth knowing. Google's Googlebot token covers Search, Discover, Images, Video and News; more specific tokens like Googlebot-Image let you control one product (Google's common crawlers). And Apple says that if robots.txt does not mention Applebot but mentions Googlebot, Applebot follows the Googlebot instructions (About Applebot).

Which rule wins

Within a group, the most specific rule applies, meaning the one with the longest matching path. When an allow and a disallow rule match equally, the least restrictive one, allow, wins. Order in the file does not matter.

RulesURLResult
Disallow: /shop/ and Allow: /shop/sale//shop/sale/bootsAllowed (longer match)
Disallow: / and Allow: /$/Allowed; every other URL blocked
Disallow: /*.php and Allow: /index.php/index.phpAllowed
Disallow: /page/pages/aboutBlocked (prefix match)
Disallow: (empty)anythingAllowed

How status codes change everything

Crawlers request /robots.txt before anything else, and its HTTP status matters as much as its content. From Google's specification and RFC 9309:

robots.txt answersGoogle's behaviorRFC 9309
2xxProcesses the file as servedUse the rules
3xxFollows at least five hops, then treats it as a 404; does not follow meta refresh or JavaScriptFollow at least five redirects
4xx except 429As if no robots.txt existed: no restrictionsMay access any resource
429, 5xx, timeoutsStops crawling for 12 hours while retrying, then uses the last good copy for up to 30 days; if there is none, assumes no restrictionsMust assume complete disallow

The practical consequence: a 404 for robots.txt is harmless, but a firewall or server that answers 500 or 503 for the file can stop crawling of the whole site. Google also warns not to use 401 or 403 to limit crawl rate.

Two limits round it out: Google caches the file for up to 24 hours, so changes are not instant, and it ignores content after 500 KiB. The file must be UTF-8.

robots.txt vs noindex

Google's noindex documentation describes the trap: if robots.txt blocks a page, the crawler never sees its noindex rule, and the page can still appear in results. The right tool depends on the goal:

GoalUse
Keep a page out of search resultsnoindex meta tag or X-Robots-Tag: noindex header, with crawling allowed
Stop crawlers wasting requests on endless filters or internal searchDisallow in robots.txt
Keep private content privateAuthentication; robots.txt is public and anyone can read it
Remove a page that is already indexednoindex or a 404/410, then let Google recrawl

Copy-ready robots.txt examples

Allow everything and list the sitemap (the right file for most small sites):

User-agent: *
Disallow:

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

A typical online shop:

User-agent: *
Disallow: /cart/
Disallow: /checkout/
Disallow: /account/
Disallow: /*?sort=
Disallow: /*?filter=

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

A staging site (and only a staging site; protect it with a password too):

User-agent: *
Disallow: /

AI search allowed, AI training blocked:

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

User-agent: GPTBot
User-agent: ClaudeBot
User-agent: Google-Extended
User-agent: CCBot
Disallow: /

User-agent: *
Disallow: /admin/

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

Blocking Google-Extended does not affect Google Search; Google says it "does not impact a site's inclusion in Google Search nor is it used as a ranking signal." AI Overviews and AI Mode run on Googlebot (AI features and your website). OpenAI says opting out of OAI-SearchBot keeps you out of ChatGPT search answers, so do not block it unless that is what you want (OpenAI crawlers). Our AI crawlers guide covers every AI token.

Do not block CSS, JavaScript or images that pages need to render. Google says you can block unimportant resources if pages "won't be significantly affected by the loss", but blocking files that carry your content or layout stops Google from understanding the page.

How the Searvia robots.txt checker works

The robots.txt checker runs the same engine as our website SEO checker: enter a domain or a page address and it reads that page (your home page if you enter only a domain) and the site files around it, runs 38 checks in about 20 seconds, and shows the four checks this tool is about first. Here is what each one does.

robots.txt (medium priority). The checker follows the page to its final address, then requests /robots.txt on that same host, following redirects. It reads the status code the way the table above does: a 404 or another 4xx means no file, a 5xx, a 429 or no answer means the file is unreachable, and a 200 that returns an HTML page is not a valid robots.txt. It parses the file the way RFC 9309 describes: User-agent groups (several lines may share one set of rules), merged duplicate groups, the * fallback, Allow and Disallow with * and $ wildcards, comments, longest match with ties going to allow, and Sitemap lines. It then asks whether Googlebot may fetch the home page path / and, if you entered an inner page, that page's path.

AI crawler access (high priority). The same parser runs for 10 crawler tokens: OAI-SearchBot, ChatGPT-User, PerplexityBot, Claude-SearchBot, Claude-User, Googlebot and Bingbot (labeled AI search), and GPTBot, ClaudeBot and CCBot (labeled AI training), plus Google-Extended and Applebot-Extended, which are labeled as AI training opt-out tokens because they are not crawlers. It also sends one request that identifies as GPTBot to see whether a firewall refuses it with 401, 403, 429 or 503; since the request does not come from OpenAI's addresses, a refusal is a warning, not proof. The check fails if any search token is blocked or robots.txt is unreachable; blocked training tokens are listed but treated as your choice.

XML sitemap (medium priority). It tries every Sitemap: line in your robots.txt, then /sitemap.xml and /sitemap_index.xml (up to four addresses), and passes on the first that answers 200 with a <urlset> or <sitemapindex>, showing the number of URLs.

Indexing allowed (high priority). It looks for noindex in a robots or googlebot meta tag on the page and in the X-Robots-Tag response header. Either one fails the check, because it keeps the page out of results whatever robots.txt says.

What it does not test

Reading the result

MessageMeaningPriority
robots.txt is present and lets search engines in.Exists; Googlebot may crawl /None
robots.txt blocks Google from the whole site.Googlebot's group, or *, disallows /Fix today
robots.txt blocks Google from this page.Googlebot's group, or *, disallows the page you enteredFix today
robots.txt answers with status N. / robots.txt could not be reached.A 5xx or 429, or no answer: Google pauses crawlingFix today
robots.txt returns an HTML page instead of crawl rules.A web page is served at /robots.txt with status 200This week
No robots.txt file was found, so crawlers may visit every page.A 404 or another 4xxOptional
robots.txt blocks N AI search crawlers.A search or user-fetch AI token cannot read the pageFix if you want AI citations
No XML sitemap was found in robots.txt or at /sitemap.xml.No sitemap at the usual placesThis week
A noindex meta tag blocks indexing. / An X-Robots-Tag header blocks indexing.The page asks to be left out of searchFix today

The report gives an A+ to F grade for all 38 checks, weighted by priority (high 10, medium 5, low 2; warnings earn half), a "Fix these first" list and a shareable link. Each check also shows what share of audited sites pass it.

How to fix every problem the checker reports

robots.txt blocks Google from the whole site

robots.txt is missing, unreachable or an HTML page

The message tells you which case you have; confirm the status code with:

curl -I https://yourdomain.com/robots.txt

robots.txt blocks AI search crawlers

Find the group each blocked token uses (its own, or *) and decide your policy per token. Allow OAI-SearchBot, Claude-SearchBot and PerplexityBot if you want to be cited in ChatGPT, Claude and Perplexity answers; block training tokens separately if you wish. Remember that a named group does not inherit the * rules. If the firewall test gave a warning instead, the fix is in your CDN or WAF settings, not in robots.txt; see the AI crawlers guide.

No XML sitemap was found

A noindex tag or X-Robots-Tag header blocks indexing

Worked example (hypothetical)

The following is a hypothetical example, not real data. Oakridge Dental, an invented clinic, relaunches its site and loses most of its Google traffic within two weeks. The robots.txt checker reports:

CheckResult
robots.txtFail: "robots.txt blocks Google from the whole site."
AI crawler accessFail: "robots.txt blocks 7 AI search crawlers."
XML sitemapPass: sitemap index found
Indexing allowedPass

The file contains only User-agent: * and Disallow: /, copied from the staging server by the deploy script. The fix took ten minutes: the team replaced the file with the "allow everything" example plus the sitemap line, excluded robots.txt from the staging sync, requested a recrawl in Search Console and reran the checker, which passed. Because the file also blocked Bingbot and the AI search crawlers, the same fix restored the clinic's eligibility for Bing, Copilot and AI answers.

A 15-minute robots.txt checklist

How Searvia helps

The free robots.txt checker tests your file for Googlebot, 9 other AI and search crawlers and 2 AI training opt-out tokens, finds your sitemap and checks the noindex signals in one shareable report. For the rest of the site, the site audit in a Searvia account crawls your pages the way a search engine does, respects your robots.txt, and flags noindex pages in the sitemap, broken pages and redirects every week, so a bad deploy is caught within days instead of after a traffic drop. Connect Search Console to see "Blocked by robots.txt" and indexing trends next to the audit, and read our technical SEO audit guide for where robots.txt fits in the full checklist.

Frequently Asked Questions

What is robots.txt?
robots.txt is a plain text file at the root of a host, for example https://www.example.com/robots.txt, that tells crawlers which URLs they may fetch. It is defined by RFC 9309, the Robots Exclusion Protocol. Rules are grouped by user agent, such as Googlebot or GPTBot, and use Allow and Disallow lines with URL paths. Well-behaved crawlers obey it, but it is not access control.
Does robots.txt stop a page from appearing in Google?
No. Google says robots.txt is not a mechanism for keeping a web page out of Google: a disallowed URL can still be indexed if other pages link to it, usually shown without a description. To keep a page out of results, allow crawling and add a noindex meta tag or X-Robots-Tag header, or protect the page with a password.
What happens if my site has no robots.txt?
If /robots.txt returns 404 or another 4xx status (except 429), Google and RFC 9309 treat it as if there were no restrictions, so the whole site may be crawled. That is fine for most sites. A 5xx error or timeout is different: Google stops crawling for 12 hours and then relies on its last cached copy, and RFC 9309 says crawlers must assume complete disallow.
Does Google support crawl-delay or noindex in robots.txt?
No. Google supports only four fields in robots.txt: user-agent, allow, disallow and sitemap. It ignores crawl-delay and any other lines. Some other crawlers do read crawl-delay; Anthropic, for example, says its bots support it. To keep pages out of Google's index, use a noindex meta tag or X-Robots-Tag header instead.
How do I test my robots.txt file?
Run a robots.txt checker to see whether the file exists, whether it blocks Googlebot and AI crawlers from the site, and whether it lists your sitemap. Then use Google Search Console's robots.txt report to see which files Google fetched and any parsing problems, and the URL Inspection tool to check whether a specific URL is blocked.

Sources

  1. RFC 9309: Robots Exclusion Protocol – IETF
  2. How Google interprets the robots.txt specification – Google Search Central
  3. Introduction to robots.txt – Google Search Central
  4. Block Search indexing with noindex – Google Search Central
  5. robots.txt report – Search Console Help
  6. Google's common crawlers – Google Search Central
  7. About Applebot – Apple Support
  8. Overview of OpenAI Crawlers – OpenAI
  9. Does Anthropic crawl data from the web, and how can site owners block the crawler? – Claude Help Center
  10. Build and submit a sitemap – Google Search Central
  11. AI features and your website – Google Search Central

Keep Reading