robots.txt Crawler Rules, Syntax, Path Matching, and Limits
How robots.txt controls crawler access, which directives work, how Google and Bing interpret rules, and what to use instead for indexing.
This page centers on how major search engines document the Robots Exclusion Protocol (REP) in a root robots.txt file. Most detail here comes from Google’s interpretation of the robots.txt specification and related Google Search Central material, aligned with RFC 9309. Bing Webmaster Tools guidance on creating robots.txt adds a few crawler-specific differences.
robots.txt: what it controls (and what it does not)
Section titled “robots.txt: what it controls (and what it does not)”A robots.txt file tells crawlers which URLs they may fetch on your site. Google’s introduction to robots.txt states plainly that it is used mainly to manage crawler traffic and avoid overloading your server—not as the primary way to keep a page out of search results.
A robots.txt file tells search engine crawlers which URLs the crawler can access on your site. This is used mainly to avoid overloading your site with requests; it is not a mechanism for keeping a web page out of Google.
— Google, Introduction to robots.txt
RFC 9309 adds that these rules are a request to crawlers, not server-side access control:
These rules are not a form of access authorization.
If the goal is to hide a URL from results, use page-level controls (noindex meta tag or X-Robots-Tag), authentication, removal tools, or HTTP 404/410—not robots.txt alone. Google’s note on unsupported rules in robots.txt lists those alternatives when publishers mistakenly relied on non-standard robots.txt indexing directives.
File placement, scope, and format
Section titled “File placement, scope, and format”Where robots.txt must live
Section titled “Where robots.txt must live”Rules belong in a single file named robots.txt at the root of each host (protocol + hostname + port), not in subfolders. See How to write and submit a robots.txt file and Google’s file location and range of validity section.
A file at https://example.com/robots.txt applies to URLs on that same scheme, host, and port—not to http://example.com/, other subdomains, or https://example.com:8181/ unless a separate robots.txt exists there. Subdirectory paths such as https://example.com/folder/robots.txt are not valid REP locations.
Encoding, size, and caching
Section titled “Encoding, size, and caching”Google requires UTF-8 plain text, ignores a leading BOM, and skips content beyond 500 kibibytes (KiB). RFC 9309 sets the same minimum parse size for implementers.
Google enforces a robots.txt file size limit of 500 kibibytes (KiB). Content which is after the maximum file size is ignored.
— Google, How Google interprets the robots.txt specification
Chrome Lighthouse’s invalid robots.txt audit warns that engines may stop parsing mid-file if the file exceeds 500 KiB—use path patterns (for example disallow: /*.pdf) instead of listing every URL.
Google generally caches robots.txt for up to 24 hours, and may respect Cache-Control max-age. After you upload changes, crawlers refresh on their own; for a faster refresh Google documents Request a recrawl in the robots.txt report.
Supported directives: what Google parses
Section titled “Supported directives: what Google parses”Google’s crawlers support these fields in the file (syntax section):
| Field | Role |
|---|---|
user-agent |
Names the crawler group (product token or *) |
allow |
Path prefix that may be crawled |
disallow |
Path prefix that must not be crawled |
sitemap |
Full URL of a sitemap (does not end a rule group) |
Google supports the following fields (other fields such as crawl-delay aren’t supported):
— Google, How Google interprets the robots.txt specification
Lines use field: value, field names are case-insensitive, and # starts a comment. Empty disallow: means no crawl restrictions for that group. Rules without a path are ignored.
The sitemap line is informational: parsers must not let it terminate a group. Google gives the example where user-agent: a and user-agent: b end up sharing one disallow: / because the sitemap line does not break grouping—see Grouping of rules.
Unsupported or retired rules (noindex, crawl-delay, nofollow)
Section titled “Unsupported or retired rules (noindex, crawl-delay, nofollow)”Historically, some sites used unpublished lines such as noindex, nofollow, or crawl-delay. Google never documented noindex in robots.txt for Googlebot; usage was rare and often contradicted other rules.
In the interest of maintaining a healthy ecosystem and preparing for potential future open source releases, we’re retiring all code that handles unsupported and unpublished rules (such as noindex) on September 1, 2019.
For Google, use noindex via HTML or response headers instead. Bing’s robots.txt help still shows Crawl-delay in a Bingbot-only section as an optional example—do not assume Google or all crawlers honor it.
User-agent groups: how crawlers pick rules
Section titled “User-agent groups: how crawlers pick rules”Groups and merging (Google)
Section titled “Groups and merging (Google)”A group is one or more user-agent lines followed by allow/disallow rules. For a given crawl, Google uses the most specific matching user-agent group; order in the file does not matter. Multiple groups for the same agent are merged internally. Agent-specific groups are not combined with the * group.
Dedicated agents such as Googlebot-News let publishers split web search and news crawling; see New User Agent for News. User-agent: * matches all crawlers except AdsBot crawlers, which must be named explicitly—see How to write robots.txt rules and Troubleshoot uncrawlable landing pages.
Bingbot and the generic * section
Section titled “Bingbot and the generic * section”Bing documents an important maintenance rule:
On finding a specific set of instructions for itself, Bingbot will ignore the directives listed in the generic section, so you need to repeat all the general directives in addition to the specific directives you created for it in specific section of the file.
— Microsoft (Bing), How to create a robots.txt file
Google’s model differs: only the matched group(s) apply, with merging for duplicate product tokens—not “inherit everything from * unless repeated.” When tuning for both Googlebot and Bingbot, validate each engine’s behavior separately.
Path matching: wildcards, specificity, and conflicts
Section titled “Path matching: wildcards, specificity, and conflicts”Google, Bing, and other major engines support * (zero or more characters) and $ (end of URL path) in rule paths. Paths are case-sensitive; they must start with /. Google compares percent-encoded forms per RFC 9309 Section 2.2.2 and treats raw UTF-8 and encoded paths equivalently when canonicalized.
When several rules match one URL:
- Most specific path wins (longer matching rule).
- If rules conflict at the same specificity, Google uses the least restrictive rule (prefer
allowoverdisallow).
Examples appear in Google’s Order of precedence for rules—for instance allow: /p beats disallow: / for https://example.com/page, while disallow: /*.htm can beat allow: /page when the disallow pattern is more specific.
Common patterns (block PDFs, allow a public folder only, per-image blocks) are collected in Useful robots.txt rules.
Crawling blocked by disallow vs removing URLs from search
Section titled “Crawling blocked by disallow vs removing URLs from search”These are related but not the same:
disallow: Google won’t crawl the URL for that agent; it generally won’t index content it cannot fetch, but the URL may still appear without a snippet if linked elsewhere.- Indexing: Use
noindex, login walls,404/410, or Search Console removal—see Introduction to robots.txt and Google’s unsupported-rules post.
Google can’t index the content of pages which are disallowed for crawling, but it may still index the URL and show it in search results without a snippet.
— Google, How Google interprets the robots.txt specification
Page-level REP (<meta name="robots"> or X-Robots-Tag) applies only if the crawler is allowed to fetch the URL; see Robots Refresher: page-level granularity. Broad path blocks often belong in robots.txt; per-URL indexing preferences belong on the response.
Standardization, open-source parser, and testing tools
Section titled “Standardization, open-source parser, and testing tools”Google contributed an IETF draft that became RFC 9309; see Formalizing the Robots Exclusion Protocol Specification. The production parser used by Googlebot is open source at google/robotstxt (announcement).
The bundled robots_main binary tests a URL against a file locally:
bazel run robots_main -- ~/local/path/to/robots.txt YourBot https://example.com/urlExit code 0 means ALLOWED, 1 means DISALLOWED. The library matches parsing and percent-encoding like production Googlebot but does not simulate crawler-specific logic outside REP (for example image crawlers inheriting Googlebot rules)—see Notes in the GitHub repository.
Common mistakes and format checks
Section titled “Common mistakes and format checks”| Mistake | Why it hurts |
|---|---|
noindex (or other non-standard lines) in robots.txt |
Ignored by Google; gives a false sense of blocking indexing |
allow/disallow before the first user-agent |
No crawler follows orphan directives (Lighthouse SEO audit) |
Expecting disallow to hide URLs completely |
URLs may still be discovered via links |
Bing-specific section without repeating * rules |
Bingbot drops generic rules when a Bingbot block exists |
File over 500 KiB or invalid patterns ($ mid-path, paths not starting with / or *) |
Partial or wrong parsing |
| Blocking CSS/JS needed for rendering | Hurts analysis; intro guidance warns against blocking critical resources |
To create and deploy a file: name it robots.txt, add groups, upload to the site root, then test—see How to write and submit a robots.txt file. Updates follow Update your robots.txt file. You do not submit the file manually; crawlers fetch /robots.txt automatically (Bing help).
How to check this on your site
Section titled “How to check this on your site”-
Open
https://your-domain/robots.txtin a private window and confirm UTF-8 plain text at the site root, as described in How to write and submit a robots.txt file. -
Copy the live file into Google’s open-source robots.txt library
robots_main(or another REP tester that uses it) and check critical URLs and user agents (Googlebot,Bingbot, any dedicated bots you target). -
In Google Search Console, use the robots.txt report and Request a recrawl if you need cache refresh within the usual ~24-hour window.
-
Run the Lighthouse
robots.txtis not valid audit on your property host to catch syntax, ordering, and size issues. -
You can check automatically in Answerwell (our tool): https://answerwell.org/workspace
Report an error or ask a question
Section titled “Report an error or ask a question”If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact wording you are asking about.