Most robots.txt advice runs in one direction: let every crawler in, then fence off a few areas. Sometimes you want the reverse. Perhaps the site is a staging copy, a private project, or a small site that only cares about one search engine. Then the question becomes: how do you welcome one or two named crawlers and tell every other crawler to fetch nothing at all?
Robots.txt can express that, and the shape of the answer is two rule groups. One group names the bots you want and sets their rules. A second group, for everyone else, disallows the whole site. This guide explains how a crawler decides which group applies to it, then builds the pattern with the free Robots.txt Generator on Ovatly. It is equally clear about the limit: crawling instructions in a public file, touching neither indexing nor security.
Contents
- Quick answer
- How a crawler chooses its rule group
- The two-group pattern
- Tokens: real names and placeholders
- How to build the file, step by step
- Worked example: one named crawler, everyone else blocked
- Limitations
- Common mistakes
- FAQs
- Conclusion
Quick answer
Name the bots you want in their own group and give that group light rules: no Disallow lines at all, or only the few areas those crawlers should still skip. Then add a second group headed User-agent: * with a single rule, Disallow: /, which blocks every path. A crawler named in its own group follows that group, so your chosen bots keep their access, while every unnamed crawler falls under the wildcard group and is told to fetch nothing. Build both groups in the Robots.txt Generator, test the result, and place the file at the root of your domain.
How a crawler chooses its rule group
A robots.txt file is a set of rule groups. Each group opens by listing the user agents it applies to, then gives the paths those crawlers may not fetch, plus any Allow lines that reopen part of a blocked area. The token * means all crawlers, so a group headed with * is the default set of rules for the whole web's bots.
The generator's steps contain the key mechanic: you add another group when one crawler needs different rules. A crawler that is named in its own group follows that group's rules. The wildcard group is what a crawler uses when no group names it. Within a group, matching is by path prefix, and when a Disallow and an Allow both match a path, the longest pattern wins. Keep those three facts in mind, and the allow-only pattern is just an arrangement of them.
The two-group pattern
The first group names your chosen crawlers. Give it the lightest rules that still make sense: perhaps an empty set of blocks, so those bots may fetch everything, or a short list such as /admin/ and /tmp/ for areas no crawler needs. An empty Disallow means nothing is blocked for that group, so a named group with no Disallow lines is a full welcome.
The second group is the wall. Head it with * and give it one rule, Disallow: /. The path / is the root prefix, so the rule covers every path on the host. Every crawler not named in the first group lands here and is told to fetch nothing. Two consequences follow. First, the pattern only works if you name every crawler you want to keep; a bot you forget is a bot you blocked. Second, the named crawlers are governed entirely by their own group, so whatever you write there is the whole of their access.
Tokens: real names and placeholders
A group names crawlers by their user-agent tokens, so the token has to be the one the crawler actually uses. The tool content names one directly: Googlebot, which the crawl-delay note discusses. Every other crawler has its own token, published by whoever runs it.
In your drafts and in this guide, treat any unfamiliar name as a placeholder. ExampleBot is a made-up token standing in for a real one; it matches no real crawler, and leaving it in a live file would give that group nobody to apply to. Before a file goes live, replace each placeholder with the genuine token for the crawler you mean, spelled exactly as its operator publishes it.
How to build the file, step by step
- Open the Robots.txt Generator. In the first group, list the user agents you want to allow.
- Add only the Disallow paths those crawlers should still skip, one per line, and any Allow paths that reopen part of a blocked section. Enter nothing if they may fetch everything.
- Add another group. Set its user agent to
*and give it a single Disallow path:/. - Add your sitemap URL, then copy or download the generated robots.txt.
- Test before uploading: run the file through the Robots.txt Tester with a few real paths from your site, checking both a named crawler and the wildcard view, then place the file at the root of your domain.
Worked example: one named crawler, everyone else blocked
Allowing only Googlebot, while still keeping it out of an admin area and a temporary folder, produces this file:
User-agent: Googlebot
Disallow: /admin/
Disallow: /tmp/
User-agent: *
Disallow: /
Sitemap: https://example.com/sitemap.xml
Read it the way a crawler does. Googlebot finds the group that names it and follows those rules: everything is open to it except /admin/ and /tmp/. Any other crawler finds no group with its name, falls back to the * group, and meets Disallow: /, which covers every path. The sitemap line still advertises the sitemap address to whoever reads the file. If the crawler you want is a different one, its group is identical in shape; only the token changes, from Googlebot to that crawler's real name.
Limitations
This pattern controls crawling only. It does not control indexing: a page can still appear in search results if other sites link to it, even when every crawler is blocked from fetching it, and blocking an already indexed page usually leaves its URL listed without a snippet. It is not security either. Anyone can read your robots.txt file, so the list of bots you welcome is public knowledge, and you should never list secret paths in the file, including in the named group's Disallow lines.
Coverage has edges. The file must live at the root of the host, for example https://example.com/robots.txt, and each subdomain needs its own file, so the pattern has to be repeated for every subdomain you want it to govern. Crawlers also differ in the details: crawl-delay, for example, is honoured by some crawlers such as Bing but ignored by Googlebot, so a named-group setting may not land the same way for every bot you allow. Finally, the wildcard wall is indiscriminate. Any crawler you did not name, including one you might want next year, gets the full block until you add its group.
Common mistakes
- Forgetting a crawler you actually want. Unnamed crawlers fall under the
*group and are blocked from everything. - Copying the full block list into the named group. The "allowed" bot then meets the same fences as everyone else.
- Leaving a placeholder token in the live file. A group for
ExampleBotapplies to no real crawler, so the bot you meant is governed by the wildcard block instead. - Expecting the wall to remove pages from search results. Crawling and indexing are different jobs; blocked pages can still be listed from links alone.
- Publishing private paths in the named group. The file is public, and its Disallow lines advertise the paths they name.
- Uploading the file somewhere other than the root. A robots.txt that is not at the host root is not the file crawlers look for, and subdomains need their own copies.
FAQs
What does the * user agent mean in robots.txt? It means all crawlers. A group headed by * is the set of rules every crawler falls back to unless it is named in its own group.
If a crawler has its own group, which rules does it follow? Its own group's. That is the point of adding another group when one crawler needs different rules: the named group gives that crawler its rules instead of the wildcard group's.
Does an empty Disallow line matter? "Disallow:" with nothing after it means nothing is blocked for that group. The generator only writes Disallow lines for paths you actually enter.
What is the difference between Allow and Disallow? Disallow tells crawlers not to fetch paths under a prefix; Allow reopens a more specific path inside a disallowed area. When both match, the longest pattern wins.
Does crawl-delay apply to every crawler I allow? No. Crawl-delay is honoured by some crawlers, for example Bing, but ignored by Googlebot.
Conclusion
Allowing only specific bots is a two-group arrangement: a named group with light rules for the crawlers you want, and a wildcard group with Disallow: / for everyone else. Build it in the Robots.txt Generator, test both views before uploading, and remember what the file is: public crawling instructions, not an index control and not a lock. For the opposite confusion, using a block when you actually need a page deindexed, see Disallow vs Noindex. More guides of this kind are collected under SEO Tools.