Thực chất, file robots.txt là một tập tin văn bản đơn giản (không chứa mã HTML) được đặt trong thư mục gốc của web site, ví dụ http://www.example.com/robots.txt.
-
User-agent: là đại diện của một search engine, Googlebot là spider của Google. Trong ví dụ này, chỉ các spider của Google là được phép index web site.
-
Disallow: là không cho phép thực hiện điều gì đó. ở ví dụ trên là không cho phép các spider index thư mục "cgi-bin" trong web site.
User-agent: googlebot
Disallow: /support
Nếu bạn muốn tất cả các search engine có thể index web site của bạn, nhưng không được index các trang trong thư mục "cgi-bin" thì sử dụng lệnh sau:
User-agent: *
Disallow: /cgi-bin/
- Cho phép tất cả các search engine có thể spider toàn bộ site:
User-agent: *
Disallow:
- Chặn tất cả các search engine truy cập cgi-bin
User-agent: *
Disallow: /cgi-bin/
- Không cho phép Yahoo! Slurp truy cập thư mục admin
User-agent: yahoo! Slurp
Disallow: /admin/
- Không cho phép tất cả các search engine truy cập vào bất kì khu vực nào:
User-agent: *
Disallow: /
4. File robots.txt mẫu sử dụng cho vbulletin:
User-agent: *
#Crawl-Delay: 10
Disallow: /cgi-bin/
Disallow: /forum/ajax.php
Disallow: /forum/cron.php
Disallow: /forum/attachment.php
Disallow: /forum/editpost.php
Disallow: /forum/external.php
Disallow: /forum/faq.php
Disallow: /forum/global.php
Disallow: /forum/image.php
Disallow: /forum/joinrequest.php
Disallow: /forum/login.php
Disallow: /forum/misc.php
Disallow: /forum/moderator.php
Disallow: /forum/newattatchment.php
Disallow: /forum/newreply.php
Disallow: /forum/newthread.php
Disallow: /forum/online.php
Disallow: /forum/payment_gateway.php
Disallow: /forum/payments.php
Disallow: /forum/pdfthread.php
Disallow: /forum/poll.php
Disallow: /forum/postings.php
Disallow: /forum/printthread.php
Disallow: /forum/private.php
Disallow: /forum/profile.php
Disallow: /forum/register.php
Disallow: /forum/report.php
Disallow: /forum/reputation.php
Disallow: /forum/search.php
Disallow: /forum/sendmessage.php
Disallow: /forum/subcription.php
Disallow: /forum/subcriptions.php
Disallow: /forum/threadrate.php
Disallow: /forum/usercp.php
Disallow: /forum/usernote.php
Disallow: /forum/admincp/
Disallow: /forum/images/
Disallow: /forum/modcp/
Disallow: /forum/articlebot/
Disallow: /forum/clientscript/
Disallow: /forum/customavatars/
Disallow: /forum/customprofilepics/
Disallow: /forum/files/
Disallow: /forum/cpstyles/
Disallow: /forum/images/
Disallow: /forum/includes/
Disallow:/forum/subscriptions/
Disallow:/forum/attachments/
Disallow:/forum/frm_attach/
Những điều nên tránh:
"Disallow: support # Don’t index the support directory" might be misinterepreted as "Disallow: support#Don’t index the support directory".
User-agent: *
Disallow: /cgi-bin/
Disallow: /support
User-agent: *
User-agent: *
Disallow: /support /cgi-bin/ /images/
User-agent: *
Disallow: /support
Disallow: /cgi-bin/
Disallow: /images/
+ Không nên dùng lệnh Allow trong file robots.txt, bởi vì trong web site của bạn chắc chắn sẽ có một số trang hoặc một số thành phần bạn không muốn bị người khác "nhòm ngó". nếu bạn sử dụng lệnh Allow, tất cả mọi ngóc ngách trong web site của bạn sẽ bị index!