一聚教程网:一个值得你收藏的教程网站

热门教程

搜索引擎蜘蛛程序2-搜索引擎技术

时间:2022-07-02 20:25:33 编辑:袖梨 来源:一聚教程网

 
4、 robots.txt举例
下面是一些著名站点的robots.txt:
http://www.cnn.com/robots.txt
http://www.google.com/robots.txt
http://www.ibm.com/robots.txt
http://www.sun.com/robots.txt
http://www.eachnet.com/robots.txt
5、 常见robots.txt错误
l 颠倒了顺序:
错误写成
User-agent: *
Disallow: GoogleBot
正确的应该是:
User-agent: GoogleBot
Disallow: *
l 把多个禁止命令放在一行中:
例如,错误地写成
Disallow: /css/ /cgi-bin/ /../images/
正确的应该是
Disallow: /css/
Disallow: /cgi-bin/
Disallow: /../images/
l 行前有大量空格
例如写成
Disallow: /cgi-bin/
尽管在标准没有谈到这个,但是这种方式很容易出问题。
l 404重定向到另外一个页面:
当Robot访问很多没有设置robots.txt文件的站点时,会被自动404重定向到另外一个Html页面。这时Robot常常会以处理robots.txt文件的方式处理这个Html页面文件。虽然一般这样没有什么问题,但是最好能放一个空白的robots.txt文件在站点根目录下。
l 采用大写。例如
USER-AGENT: EXCITE
DISALLOW:
虽然标准是没有大小写的,但是目录和文件名应该小写:
user-agent:GoogleBot
disallow:
l 语法中只有Disallow,没有Allow!
错误的写法是:
User-agent: Baiduspider
Disallow: /john/
allow: /jane/
l 忘记了斜杠/
错误的写做:
User-agent: Baiduspider
Disallow: css
正确的应该是
User-agent: Baiduspider
Disallow: /css/
下面一个小工具专门检查robots.txt文件的有效性:http://www.searchengineworld.com/cgi-bin/robotcheck.cgi


热门栏目