小枫客栈

淡泊以明志,宁静以致远!

« 小枫E6简约速度包(跨越)提问的智慧(How To Ask Questions The Smart Way) »

robots.txt文件用法举例

例1. 禁止所有搜索引擎访问网站的任何部分 
下载该robots.txt文件 User-agent: * 
Disallow: / 

例2. 允许所有的robot访问
User-agent: *
Disallow: 
或者
User-agent: *
Allow: /
或者也可以建一个空的robots.txt文件

例3. 仅禁止baiduspider访问您的网站
User-agent: baiduspider
Disallow: / 

例4. 仅允许baiduspider访问您的网站
User-agent: baiduspider
Disallow: 
User-agent: *
Disallow: / 

例5.禁止spider访问特定目录
  在这个例子中,该网站有三个目录对搜索引擎的访问做了限制,即robot不会访问这三个目录。需要注意的是对每一个目录必须分开声明,而不能写成 "Disallow: /cgi-bin/ /tmp/"
User-agent: *
Disallow: /cgi-bin/
Disallow: /tmp/
Disallow: /~joe/ 

例6. 允许访问特定目录中的部分url
User-agent: *
Allow: /cgi-bin/see
Allow: /tmp/hi
Allow: /~joe/look
Disallow: /cgi-bin/
Disallow: /tmp/
Disallow: /~joe/ 

例7. 使用"*"限制访问url
   禁止访问/cgi-bin/目录下的所有以".htm"为后缀的URL(包含子目录)
User-agent: *
Disallow: /cgi-bin/*.htm

例8. 使用"$"限制访问url
   仅允许访问以".htm"为后缀的URL。 User-agent: *
Allow: .htm$
Disallow: / 

例9. 禁止访问网站中所有的动态页面
 User-agent: *
Disallow: /*?* 

摘自网络

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

日历

最新评论及回复

最近发表

Copyright © 2006 - 2012 Xiaofeng. All Rights Reserved.
豫ICP备07012919号