TapCub is live — analytics, insights and live chat, free on one platform
Glossary

What is robots.txt? Syntax and matching rules explained

robots.txt tells crawlers which URL paths not to fetch. How RFC 9309 picks a group and a rule, what 4xx and 5xx responses do, and why the file is a request you have to verify from server logs.

Xu An Reviewed by Lucas Hayes Also called robots txt Last updated Nov 29, 2026 Glossary

Quick answer

robots.txt is a plain-text file at the root of a host that tells crawlers which URL paths they should not fetch, using user-agent groups and allow/disallow rules defined in RFC 9309. It is a voluntary crawl directive: it does not block access and does not remove pages from search.

What is robots.txt?

robots.txt is a plain-text file at the root of a website that tells automated crawlers which URL paths they may and may not fetch. It implements the Robots Exclusion Protocol, first proposed in 1994 and published as an IETF standard, RFC 9309, in September 2022.

Two facts shape everything else on this page. First, the file is a request, not a lock: RFC 9309 states that the rules "are not a form of access authorization", and a crawler that ignores them still gets the page. Second, it controls crawling, not indexing. Google's own documentation says robots.txt is "not a mechanism for keeping a web page out of Google"; a blocked URL can still appear in results if other sites link to it, just without a description.

So the useful mental model is: robots.txt is a traffic sign for well-behaved bots. You use it to keep search engines and AI crawlers away from low-value or expensive URLs, and you verify compliance from your own server records, because the file itself proves nothing.

Where the file lives and what it contains

PropertyWhat RFC 9309 saysPractical consequence
Location/robots.txt, all lowercase, at the top-level path of the serviceexample.com/robots.txt does not cover shop.example.com or http:// vs https://; each host and protocol needs its own file
GroupsOne or more user-agent lines followed by allow and disallow rulesRules belong to a group; there is no inheritance between groups
Agent matchingCase-insensitive match on the crawler's product tokengooglebot and Googlebot are the same group
Wildcards* means zero or more characters; $ anchors the end of the path/*?sort= blocks any URL with a sort parameter; /*.pdf$ blocks PDFs
SizeCrawlers must parse at least 500 kibibytesRules past that point may be ignored; Google stops at 500 KiB
RedirectsCrawlers should follow at least five consecutive redirectsA redirect chain to the file longer than that may be treated as unavailable
CachingCrawlers should not use a cached copy for more than 24 hours, unless the file is unreachableA fix can take up to a day to be picked up

Sitemap: lines are allowed and widely used, but they sit outside the core rules. Crawl-delay is not part of RFC 9309; some crawlers honour it, Google does not.

How a crawler picks a group and a rule

The matching logic has three steps, all from RFC 9309 section 2.2:

  1. Find the group. The crawler looks for the group whose user-agent matches its product token. If several groups match the same token, their rules are merged. Only if no group matches does it fall back to the * group.
  2. Find matching rules. Every allow and disallow path in that group is compared with the URL path, including the query string.
  3. Pick the most specific rule. "The most specific match is the match that has the most octets", in plain terms the longest matching path. If an allow and a disallow are equally long, allow wins. If nothing matches, the URL is allowed.

Here is a worked example file for a shop:

User-agent: Googlebot
Disallow: /checkout/
Allow: /checkout/help
Disallow: /*?sort=

User-agent: GPTBot
Disallow: /

User-agent: *
Disallow: /admin/
Disallow: /search
Allow: /search/help$

Each row below was checked with a small Python implementation of the longest-match rule:

CrawlerURL pathGroup usedWinning ruleResult
Googlebot/checkout/helpGooglebotAllow: /checkout/help (14 characters beats 10)Allowed
Googlebot/checkout/payGooglebotDisallow: /checkout/Blocked
Googlebot/shoes?sort=priceGooglebotDisallow: /*?sort=Blocked
Googlebot/admin/GooglebotNone (the * group is not inherited)Allowed
GPTBot/blog/robots-guideGPTBotDisallow: /Blocked
Bingbot/search?q=boots*Disallow: /searchBlocked
Bingbot/search/help*Allow: /search/help$Allowed
Bingbot/search/help/returns*Disallow: /search (the $ stops the allow)Blocked

The fourth row is the mistake most sites make: once you write a named group for a crawler, that crawler ignores everything in User-agent: *. If /admin/ should be closed to Googlebot too, the line must be repeated inside the Googlebot group. Blocking an entire site is covered separately in robots.txt disallow all.

What happens when the file cannot be fetched

Crawlers fetch the file before crawling, and the HTTP status changes the outcome:

Status when fetching /robots.txtRFC 9309 behaviourWhat it means for you
2xxParse and obey the rulesNormal case
3xxFollow at least five redirects, then treat the target as the fileKeep the redirect short and on the same rules
4xx ("unavailable")The crawler may access any resourceA missing file means "crawl everything", including a 403
5xx or network error ("unreachable")The crawler must assume complete disallowAn outage on the file can stop all crawling
Unreachable for a long time (the RFC's example is 30 days)The crawler may treat the file as unavailable or keep using its cached copyA long outage can flip from "nothing" to "everything"

The 4xx and 5xx rows run in opposite directions, which surprises people. Returning 403 to block a crawler from the file does not protect the site; it tells the crawler there are no rules.

What robots.txt cannot do

  • It cannot stop a fetch. Any client can request a disallowed path. RFC 9309 says the protocol "is not a substitute for valid content security measures". Private pages need authentication.
  • It cannot remove a page from search. A disallowed URL that is linked from elsewhere can be indexed with no snippet. To keep a page out of results, let it be crawled and serve noindex.
  • It can expose what you hide. The file is public. Listing /internal-reports/ tells every reader where to look.
  • It cannot tell you who obeyed. The file has no reporting. Only access logs or server-side records show whether a crawler fetched a disallowed path.

robots.txt vs noindex vs X-Robots-Tag

ControlWhere it livesWhat it controlsCrawler must fetch the page?
robots.txtOne file per hostWhether a URL is fetchedNo, the URL is never requested
<meta name="robots" content="noindex">Inside the HTML pageWhether the page is indexedYes, it has to read the tag
X-Robots-TagHTTP response headerIndexing for any file type, such as PDFsYes, it has to read the header

The practical rule: if you disallow a URL in robots.txt, a noindex on that URL is never seen. Pick one job per URL: robots.txt for crawl load, noindex or X-Robots-Tag for search visibility.

Common mistakes

  1. Blocking CSS and JavaScript. Search engines render pages; blocking /assets/ can make pages look broken to them.
  2. Assuming the * group applies to named bots. See the Googlebot /admin/ row above.
  3. Using robots.txt to hide staging or private data. Use authentication; the file is a public list.
  4. Disallowing a page to de-index it. The page stays in the index without a snippet; serve noindex instead.
  5. Forgetting subdomains. blog.example.com and cdn.example.com each need their own file.
  6. Serving 5xx on the file during deploys. Per RFC 9309 that reads as "disallow everything" until the next successful fetch.

Checking whether crawlers obey robots.txt in TapCub

Take the example file above. You added Disallow: / for GPTBot and want to know whether the crawler respects it. In TapCub:

  1. Send server-side records. The page script only sees bots that run JavaScript and never sees status codes. Send access-log lines through the log import API (it keeps only requests classified as bots) or server events, so every crawler request is counted. See check crawl health.
  2. Open Monitoring › Crawler compliance. TapCub fetches your robots.txt and compares it with real fetches. It lists three violation types: fetched while blocked globally, fetched a path marked disallowed, and fetched sooner than the declared delay. A GPTBot row here is your evidence that the file was ignored. The page can also draft rules such as "block training crawlers" for you to publish; the file still cannot stop a fetch.
  3. Check the volume in Web analytics › Bots. The All bots tab lists each crawler's operator, purpose, requests, pages visited, most common status code and last-seen time, kept out of human visitor counts. Several tokens from one operator share a row.
  4. Watch search crawlers in Monitoring › Crawl health. Fetches, success rate, 404s and 5xx per engine show whether a rule change cut crawling of pages you still want indexed.

Adding a crawler to TapCub's exclusion rules only stops TapCub from counting it; to refuse requests you need a server or firewall rule.

Sources

Was this explanation clear?

We use your answers to fix and expand this page.

Xu An

Customer Experience Consultant

Writes about live chat, visitor conversations, and self-service, sharing practical ways to make customer communication clearer and more effective.

FAQ

Questions people ask

Short answers to the follow-up questions that come up most.

Still have a question?

Chat with the team behind TapCub — we usually reply within a few hours on business days.

Is robots.txt legally binding?

No. RFC 9309 says the rules are not a form of access authorization, and compliance is voluntary. Reputable search engines follow it, but any client can still request a disallowed URL. Protect private content with authentication, not with robots.txt.

Does robots.txt stop a page from appearing in Google?

Not reliably. It stops crawling, not indexing. A disallowed URL linked from other sites can still be indexed without a description. To keep a page out of results, allow crawling and serve a noindex meta tag or X-Robots-Tag header.

What happens if there is no robots.txt file?

If the file returns a 4xx status such as 404, RFC 9309 lets crawlers access any resource on the host. If it returns a 5xx error or cannot be reached, crawlers must assume everything is disallowed until they can fetch it again.

How do I check whether a crawler ignores my robots.txt?

Compare the rules with server-side records of real fetches: access logs or server events that include the user agent, path and status code. A page script cannot see crawlers that skip JavaScript, so log-based data is needed for a complete picture.

See this number on your own site

Add one script tag for web and apps, and the first reports fill in within minutes.

See your data clearly. Find your growth.

Every click, backed by data. Install one line of code and see your first numbers in a minute.

No credit card · Free plans for analytics and chat · Cookieless analytics