robots.txt基本写法
当一个搜索蜘蛛访问一个站点时,它会首先检查该站点根目录下是否存在robots.txt,如果存在,搜索机器人就会按照该文件中的内容来确定访问的范围;如果该文件不存在,所有的搜索蜘蛛将能够访问网站上所有没有被口令保护的页面。
robots.txt必须放置在一个站点的根目录下,而且文件名必须全部小写。
User-Agent: 适用什么规则的蜘蛛
Disallow: 要拦截的网页
A.禁止所有搜索引擎访问网站的任何部分:
User-agent:*
Disallow:/
B.允许所有的robot访问
User-agent:*
Disallow:
C.禁止所有搜索引擎访问网站的几个部分(下例中的cgi-bin,tmp,private目录)
User-agent:*
Disallow:/cgi-bin/
Disallow:/tmp/
Disallow:/private/
D禁止某个搜索引擎的访问
User-agent:BadBot
Disallow:/
E.只允许某个搜索引擎的访问(下例中的WebCrawler)
User-agent:WebCrawler
Disallow:
User-agent:*
Disallow:/
常见搜索引擎机器人Robots名字:
百度: Baiduspider
谷歌: Googlebot