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.txtthat tells crawlers which URLs they may fetch. Rules are grouped byUser-agent; a crawler uses the group that names it, or the*group if none does, and the longest matchingAlloworDisallowpath wins. It controls crawling, not indexing: to keep a page out of Google, usenoindex. 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:
- It is a request, not a lock. RFC 9309 says the rules "are not a form of access authorization." Respectable crawlers obey; others might not. Protect private content with authentication.
- It applies per host, protocol and port.
https://www.example.com/robots.txtdoes not coverhttps://shop.example.comorhttp://www.example.com. Each needs its own file, and Google does not look for robots.txt files in subdirectories. - Different crawlers interpret syntax differently. Stick to the standard fields and simple patterns, and every major crawler will read them the same way.
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
| Field | Supported by Google | What it does |
|---|---|---|
user-agent | Yes | Names the crawler the group applies to; * means all others |
disallow | Yes | A path prefix the crawler should not fetch; empty means nothing is disallowed |
allow | Yes | A path prefix the crawler may fetch, used to make exceptions |
sitemap | Yes | The absolute URL of a sitemap; not tied to any group |
crawl-delay | No | Ignored by Google; read by some other crawlers, such as Anthropic's |
noindex and anything else | No | Ignored |
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.
| Rules | URL | Result |
|---|---|---|
Disallow: /shop/ and Allow: /shop/sale/ | /shop/sale/boots | Allowed (longer match) |
Disallow: / and Allow: /$ | / | Allowed; every other URL blocked |
Disallow: /*.php and Allow: /index.php | /index.php | Allowed |
Disallow: /page | /pages/about | Blocked (prefix match) |
Disallow: (empty) | anything | Allowed |
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 answers | Google's behavior | RFC 9309 |
|---|---|---|
| 2xx | Processes the file as served | Use the rules |
| 3xx | Follows at least five hops, then treats it as a 404; does not follow meta refresh or JavaScript | Follow at least five redirects |
| 4xx except 429 | As if no robots.txt existed: no restrictions | May access any resource |
| 429, 5xx, timeouts | Stops crawling for 12 hours while retrying, then uses the last good copy for up to 30 days; if there is none, assumes no restrictions | Must 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:
| Goal | Use |
|---|---|
| Keep a page out of search results | noindex meta tag or X-Robots-Tag: noindex header, with crawling allowed |
| Stop crawlers wasting requests on endless filters or internal search | Disallow in robots.txt |
| Keep private content private | Authentication; robots.txt is public and anyone can read it |
| Remove a page that is already indexed | noindex 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.
- Pass: the file exists and Googlebot may crawl
/and the page you entered. - Fail: the file blocks Googlebot from
/(in practice the whole site) or from the page you entered, or robots.txt is unreachable. - Warning: no file was found (a 4xx), or the file is an HTML page.
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
- One page per run. Googlebot is tested for
/and the page you enter. A rule likeDisallow: /blog/is flagged only if you enter a page under/blog/. Read the file for section-level rules, or test specific URLs in Search Console's URL Inspection. - Rules for other hosts. Only the robots.txt of the host your page ends on is read.
Reading the result
| Message | Meaning | Priority |
|---|---|---|
| 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 entered | Fix today |
| robots.txt answers with status N. / robots.txt could not be reached. | A 5xx or 429, or no answer: Google pauses crawling | Fix today |
| robots.txt returns an HTML page instead of crawl rules. | A web page is served at /robots.txt with status 200 | This week |
| No robots.txt file was found, so crawlers may visit every page. | A 404 or another 4xx | Optional |
| robots.txt blocks N AI search crawlers. | A search or user-fetch AI token cannot read the page | Fix if you want AI citations |
| No XML sitemap was found in robots.txt or at /sitemap.xml. | No sitemap at the usual places | This week |
| A noindex meta tag blocks indexing. / An X-Robots-Tag header blocks indexing. | The page asks to be left out of search | Fix 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
- Open the live file and find the group that applies to Googlebot: a
User-agent: Googlebotgroup if there is one, otherwiseUser-agent: *. - Look for
Disallow: /or a pattern likeDisallow: /*in that group. Remove it, or replace it with the specific paths you meant to block. - Find where the file comes from before editing: a static file, a CMS setting, an SEO plugin, a CDN rule or a deploy script. In Shopify, edit the
robots.txt.liquidtheme template. - Load
https://yourdomain.com/robots.txtin a private window to confirm the change is live, then rerun the robots.txt checker. - In Search Console, open the robots.txt report and choose Request a recrawl for the file. Google caches it for up to 24 hours otherwise.
- Check the Page indexing report over the following days for "Blocked by robots.txt" counts dropping.
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
- 404: harmless, but publish a simple file anyway so you can list your sitemap. Use the "allow everything" example above.
- 200 with
Content-Type: text/html: your app returns a web page for unknown URLs. Serve a real text file before the app's catch-all route. - 403: a security rule blocks the file. Allow
/robots.txtfor everyone. - 5xx or timeout: fix this first. Google stops crawling for 12 hours each time it sees it, and RFC 9309 tells crawlers to assume the whole site is disallowed.
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
- Generate a sitemap of your canonical, indexable URLs. Most CMSs do it: WordPress core serves
/wp-sitemap.xml, and Yoast SEO and Rank Math serve/sitemap_index.xml; in Next.js, addapp/sitemap.ts. - Add the absolute URL to robots.txt:
Sitemap: https://www.example.com/sitemap.xml. - Submit it in Google Search Console and Bing Webmaster Tools.
- Keep it under Google's limits of 50,000 URLs or 50 MB uncompressed per file (Build and submit a sitemap); split larger sites with a sitemap index.
A noindex tag or X-Robots-Tag header blocks indexing
- View the page source and search for
noindex. If it is in a meta tag, find the setting that adds it: an SEO plugin's per-page option, a theme setting or a staging flag. In WordPress, check Settings › Reading › Search engine visibility, which is often left on after a launch. - If the source is clean, check the headers with
curl -I https://yourdomain.com/. AnX-Robots-Tag: noindexheader usually comes from the server, a CDN rule or a hosting "staging" mode. - Remove it, then request indexing for the home page in Search Console's URL Inspection.
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:
| Check | Result |
|---|---|
| robots.txt | Fail: "robots.txt blocks Google from the whole site." |
| AI crawler access | Fail: "robots.txt blocks 7 AI search crawlers." |
| XML sitemap | Pass: sitemap index found |
| Indexing allowed | Pass |
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
- Run the free robots.txt checker and note every failing check.
- Confirm
/robots.txtanswers 200 as plain text, not 5xx or HTML. - Read every group: which crawler it names, and whether it accidentally blocks
/or key sections. - Repeat important rules in every named group; they do not inherit
*. - List your sitemap with an absolute URL.
- Make sure nothing you want out of search relies on robots.txt instead of
noindex. - After changes, request a recrawl in Search Console and recheck.
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
- RFC 9309: Robots Exclusion Protocol – IETF
- How Google interprets the robots.txt specification – Google Search Central
- Introduction to robots.txt – Google Search Central
- Block Search indexing with noindex – Google Search Central
- robots.txt report – Search Console Help
- Google's common crawlers – Google Search Central
- About Applebot – Apple Support
- Overview of OpenAI Crawlers – OpenAI
- Does Anthropic crawl data from the web, and how can site owners block the crawler? – Claude Help Center
- Build and submit a sitemap – Google Search Central
- AI features and your website – Google Search Central