Sub topic 5
Controlling Access with robots.txt
Assume you understand basic HTTP requests, web crawlers, and how search engines index pages. This chapter focuses on policy, not authentication. The robots.txt file tells cooperative crawlers which URLs they may request. It does not protect private data.
Separate crawler purposes
AI-related crawlers can have different jobs:
- Search crawlers collect pages for a search index.
- Training crawlers collect content for model training.
- User-initiated crawlers fetch a page because a person asked an assistant to inspect it.
These purposes may use different user-agent strings. A user agent is the identifier a client sends in its HTTP request. Treating every AI crawler as the same can create an unintended trade-off. For example, you might allow search indexing while declining model-training collection.
Write targeted rules
Place robots.txt at the site root, such as https://www.example.com/robots.txt. Each group starts with User-agent. Allow and Disallow then define the permitted paths for that group.
# Allow the crawler that builds ChatGPT's search index
User-agent: OAI-SearchBot
Allow: /
# Decline model-training collection
User-agent: GPTBot
Disallow: /
# Allow Perplexity's search crawler
User-agent: PerplexityBot
Allow: /
# Allow Bing's crawler
User-agent: bingbot
Allow: /
# Default policy for other crawlers
User-agent: *
Disallow:An empty Disallow means that no path is blocked by that rule. A slash means the entire site is blocked. To block only an administrative area, use a path such as Disallow: /admin/.
| Rule | Meaning |
|---|---|
| `Allow: /` | Permit all paths in the group |
| `Disallow: /private/` | Block paths under `/private/` |
| `Disallow:` | Do not block paths with this directive |
A crawler that matches a specific group should not automatically be treated as the wildcard group. Check the crawler's documentation for matching behavior, path patterns, and supported directives. User-agent names can change, so review vendor documentation instead of copying an old list indefinitely.
Visualize the decision
Verify the policy
First, test the published file from the public internet. Then inspect server logs to see whether requests arrive with the user-agent strings you expect. Logs show attempted access, not whether a crawler used the content later.
for ua in OAI-SearchBot GPTBot PerplexityBot bingbot; do
echo "$ua: $(grep -c "$ua" access.log)"
doneReview analytics separately for visits referred by AI services. A crawler request and a human referral are different signals, so measure both.
Exercise
You want pages indexed for AI search but do not want to permit model-training crawls. What should you do?
Show answer
Identify the vendor's search and training user agents, allow the search agent, disallow the training agent, publish the rules at the site root, and verify requests in server logs. Use access control for private data.