How does robots.txt work?
The rules follow the Robots Exclusion Protocol, standardised by the IETF as RFC 9309 in 2022 [2]. Crawlers look for a file named "/robots.txt", all lower case, at the top-level path of the service, and the file must be UTF-8 encoded [2]. User-agent lines pick out crawlers, and allow and disallow rules sit beneath them; when several rules match, the most specific path wins [2]. The standard requires crawlers to parse at least 500 kibibytes of the file [2].
What does robots.txt not do?
Two misreadings are common. The first is security: RFC 9309 says plainly that these rules are not a form of access authorisation, and anything that genuinely needs restricting should sit behind authentication [2]. The second is de-indexing: Google says robots.txt is not a mechanism for keeping a page out of Google, and points to a noindex directive or password protection instead [1]. In Google's words, the file is mainly there to manage crawler traffic and avoid overloading a site with requests [1].
Obeying the rules is also up to the crawler. Googlebot and other reputable crawlers follow them, but not every search engine supports every rule [1].
What does a typical rule look like?
A site that does not want crawlers wading through endlessly varying internal search results can add "Disallow: /search" under "User-agent: *". That limits requests to that path, but if the address is linked from elsewhere, keeping it out of the index still takes noindex [1].