The Rule That Didn't Apply
User-agent: *
Disallow: /admin
User-agent: Googlebot
Allow: /
You wanted Googlebot to be allowed everywhere while other crawlers stay out of /admin. What you actually wrote is that Googlebot ignores the /admin restriction entirely — and so does every other crawler, because the wildcard group and the Googlebot group are separate and only one applies.
That's the first rule of robots.txt parsing, and it catches people constantly: a crawler obeys exactly one group — the most specific one matching its name — and ignores every other group in the file.
Group Selection
A robots.txt file is a series of groups. Each group starts with one or more User-agent lines and contains the rules that follow.
A crawler:
- Scans for a group whose
User-agentmatches its own name - If found, obeys only that group
- If not found, falls back to the
*group - If there's no
*group either, it's unrestricted
The * group is not a baseline that other groups extend. It's an alternative that applies only when nothing more specific matches.
So this:
User-agent: *
Disallow: /private/
Disallow: /admin/
Crawl-delay: 10
User-agent: Bingbot
Disallow: /tmp/
Means Bingbot is free to crawl /private/ and /admin/, and ignores the crawl delay. It found its own group and stopped looking.
To restrict a named crawler, repeat every rule that should apply to it. Verbose and correct.
Multiple user-agents can share a group:
User-agent: Googlebot
User-agent: Bingbot
Disallow: /admin/
Both obey these rules; neither sees the * group.
The Robots.txt Generator produces correctly structured files:
- Select which crawlers to address.
- Specify paths to allow or disallow.
- Add your sitemap location.
- Copy the output to your site root.
Longest Match Wins, Not First Match
Within a group, the rule that applies is the one with the longest matching path — not the first one listed, and not the last.
Disallow: /products/
Allow: /products/featured/
For /products/featured/item-1:
Disallow: /products/matches, 10 charactersAllow: /products/featured/matches, 19 characters
Longest wins. The URL is allowed.
Order in the file is irrelevant. Writing the Allow first or last makes no difference.
When a matching Allow and Disallow are the same length, Allow wins. This tie-break is defined in the specification.
This is what makes precise exceptions possible:
User-agent: *
Disallow: /search
Allow: /search/popular-topics
Everything under /search is blocked except that one path.
Wildcards and Anchors
Two special characters are widely supported:
* matches any sequence of characters.
Disallow: /*.pdf$ # block PDFs
Disallow: /*?sessionid= # block URLs with a session parameter
Disallow: /*/print/ # block any path containing /print/
$ anchors to the end of the URL.
Disallow: /*.php$ # blocks /page.php
# does NOT block /page.php?id=1
That distinction matters. Without $, the pattern matches anything starting with the given prefix, so query strings and additional path segments are included.
Everything is a prefix match by default. Disallow: /admin blocks /admin, /admin/, /administrator, and /admin-panel. If you meant only the directory, write Disallow: /admin/ with the trailing slash.
Paths are case-sensitive. Disallow: /Admin/ does not block /admin/. On a case-insensitive server serving the same content at both, you need both rules.
Robots.txt Cannot Remove Anything From the Index
The most consequential misunderstanding.
Disallow prevents crawling. It does not prevent indexing.
A URL that's blocked in robots.txt can still appear in search results if other pages link to it. Search engines know the URL exists from those links, can't fetch it to see what's there, and may index it based on external signals alone — typically showing the URL with no description.
Worse: blocking a page in robots.txt prevents the crawler from reading its noindex meta tag. So the standard mistake goes:
Page is indexed and you want it removed.
→ You add Disallow: /that-page to robots.txt
→ Crawler can no longer fetch the page
→ Crawler never sees the noindex tag you also added
→ Page stays indexed indefinitely
To deindex a page: allow crawling and use noindex. Once it's dropped from the index, you can block it in robots.txt if you want to save crawl budget.
The two directives solve different problems:
| Goal | Use |
|---|---|
| Keep out of search results | noindex (meta tag or X-Robots-Tag header), crawling allowed |
| Reduce crawler load on low-value URLs | Disallow in robots.txt |
| Protect private content | Authentication. Neither of the above. |
That last row is worth emphasising. Robots.txt is a public file at a predictable location. Listing your admin paths in it tells anyone who looks exactly where they are. It's a request to well-behaved crawlers, not access control.
What Belongs in Robots.txt
Good candidates for Disallow:
- Internal search result pages, which can generate unlimited URLs
- Faceted navigation combinations with no search value
- Cart, checkout and account pages
- URLs with session identifiers or tracking parameters
- Duplicate paginated or sorted variants
- Staging or development paths on a live host
Bad candidates:
- Pages you want deindexed — use
noindexinstead - CSS and JavaScript files — blocking these prevents rendering and can cause pages to be assessed against a broken version
- Images you want in image search
- Anything requiring actual protection
The CSS and JS point catches legacy configurations. Older robots.txt files often blocked /assets/ or /static/, which was harmless when crawlers didn't render pages and is harmful now that they do.
The Sitemap Directive
Sitemap: https://example.com/sitemap.xml
Group-independent — it applies regardless of user-agent and can appear anywhere in the file. Multiple sitemap lines are allowed.
Must be an absolute URL. Relative paths are invalid.
This is a useful discovery mechanism, though submitting sitemaps directly through search console tools is more reliable.
Practical Constraints
Location is fixed. https://example.com/robots.txt, at the root, nowhere else. A file at /subfolder/robots.txt is ignored.
It's per protocol, host and port. http://example.com and https://example.com and https://www.example.com each need their own file. They're separate origins as far as robots.txt is concerned.
Subdomains need their own. blog.example.com/robots.txt is separate from example.com/robots.txt.
Size limits apply. Google documents a 500 KiB limit, with content beyond that ignored. Rarely a practical constraint.
Response codes matter. A 4xx is generally treated as no restrictions — crawl everything. A 5xx may be treated as a temporary full disallow, which means a robots.txt returning 500 during an outage can halt crawling entirely. Make sure it's served reliably.
Crawl-delay isn't universally supported. Some crawlers honour it, some ignore it, and Google doesn't use it — crawl rate is managed through their console instead.
Testing Is Worth More Than Generating
Writing a robots.txt takes two minutes. Verifying that it does what you think takes slightly longer and catches the errors.
Test specific URLs, not just the file. Pick a URL you intend to block and a URL you intend to allow, and check each against your rules. The longest-match behaviour produces results that aren't obvious from reading the file.
Check the edge cases:
- A URL with a query string against a rule without
$ - A path that's a prefix of another (
/adminversus/administrator) - Case variants
- A URL matching both an Allow and a Disallow
Verify after deploying. Fetch /robots.txt and confirm it returns 200 with text/plain and the content you expect. A CMS or CDN can intercept the path and serve something else.
Watch for a staging robots.txt reaching production. A Disallow: / from a staging environment deployed live is one of the more expensive deployment accidents there is, and it happens regularly.
FAQ
Why is my Googlebot rule not working?
Because a crawler obeys only the most specific matching group. If you created a Googlebot group, it ignores the * group entirely — every rule you want applied to it must be repeated there.
Does Disallow remove a page from search results?
No. It prevents crawling. A blocked URL can still be indexed from external links, and blocking it prevents the crawler from seeing a noindex tag.
How do I remove a page from the index?
Allow crawling and add a noindex meta tag or X-Robots-Tag header. Block it in robots.txt only after it's been dropped.
What does $ do?
Anchors the pattern to the end of the URL. Without it, /*.php matches /page.php?id=1; with $ it doesn't.
Is robots.txt case-sensitive? Path values are. The directive names aren't.
Can robots.txt protect private content? No. It's a publicly readable file containing a list of paths, honoured voluntarily. Use authentication.
The Takeaway
Two rules account for most robots.txt mistakes: a crawler reads one group and only one, and blocking a URL is not the same as removing it from the index. Both produce failures that look like the file isn't working when it's working exactly as specified — which is why testing specific URLs beats reading the file.
Generate and structure a robots.txt file free with the Robots.txt Generator at sadiqbd.com — no sign-up, instant results.