robots文件的标准写法

robots是搜索引擎访问你网站的第一站!这是一个协议!当你网站有这个文件时就会遵循这个协议!哪些文件需要它收录,哪些URL不需要它收录!我们应该怎么写呢?
首先了解:robots的语法:

1、User-agent 定义搜索引擎。一般情况下,网站里面都是:User-agent: *,这里*的意思是所有,表示定义所有的搜索引擎。比如,我想定义百度,那么就是User-agent: Baiduspider;定义google,User-agent: Googlebot。

2、Disallow 禁止爬取。如,我想禁止爬取我的admin文件夹,那就是Disallow: /admin/。禁止爬取admin文件夹下的login.html,

Disallow: /admin/login.html。

3、Allow 允许。我们都知道,在默认情况下,都是允许的。那为什么还要允许这个语法呢?举个例子:我想禁止admin文件夹下的所有文件,除了.html的网页,那怎么写呢?我们知道可以用Disallow一个一个禁止,但那样太费时间很精力了。这时候运用Allow就解决了复杂的问题,就这样写:

Allow: /admin/.html$

Disallow: /admin/。

4、$ 结束符。例:Disallow: .php$ 这句话的意思是,屏蔽所有的以.php结尾的文件,不管前面有多长的URL,如abc/aa/bb//index.php也是屏蔽的。

5、* 通配符符号0或多个任意字符。例:Disallow: *?* 这里的意思是屏蔽所有带“?”文件,也是屏蔽所有的动态URL。
robots.txt文件写法举例说明


禁止Google/百度等所有搜索引擎访问整个网站
User-agent: *
Disallow: /

允许所有的搜索引擎spider访问整个网站(Disallow:可以用Allow: /替代)
User-agent: *
Disallow:

禁止Baiduspider访问您的网站,Google等其他搜索引擎不阻止
User-agent: Baiduspider
Disallow: /

只允许Google spider: Googlebot访问您的网站,禁止百度等其他搜索引擎
User-agent: Googlebot
Disallow:
User-agent: *
Disallow: /

禁止搜索引擎蜘蛛spider访问指定目录
  (spider不访问这几个目录。每个目录要分开声明,不能合在一起)
User-agent: *
Disallow: /cgi-bin/
Disallow: /admin/
Disallow: /~jjjj/

禁止搜索引擎spider访问指定目录,但允许访问该指定目录的某个子目录
User-agent: *
Allow: /admin/far
Disallow: /admin/

使用通配符星号"*"设置禁止访问的url
   (禁止所有搜索引擎抓取/cgi-bin/目录下的所有以".html"格式的网页(包含子目录))
User-agent: *
Disallow: /cgi-bin/*.html

使用美元符号"$"设置禁止访问某一后缀的文件
   (只允许访问以".html"格式的网页文件。)
User-agent: *
Allow: .html$
Disallow: /

阻止google、百度等所有搜索引擎访问网站中所有带有?的动态网址页面
User-agent: *
Disallow: /*?*

阻止Google spider:Googlebot访问网站上某种格式的图片
  (禁止访问.jpg 格式的图片)
User-agent: Googlebot
Disallow: .jpg$

只允许Google spider:Googlebot抓取网页和.gif格式图片
   (Googlebot只能抓取gif格式的图片和网页,其他格式的图片被禁止;
            其他搜索引擎未设置)
User-agent: Googlebot
Allow: .gif$
Disallow: .jpg$
.......

只禁止Google spider:Googlebot抓取.jpg格式图片
           (其他搜索引擎和其他格式图片没有禁止)
User-agent: Googlebot
Disallow: .jpg$



声明网站地图sitemap

这个告诉搜索引擎你的sitemap在哪,如:

Sitemap: http://www.139521.info/sitemap.xml
Google和百度对robots.txt文件的介绍: Google robotstxt,百度 robots.txt。

PS:

国内的搜索引擎蜘蛛

百度蜘蛛:baiduspider

搜狗蜘蛛:sogou spider

有道蜘蛛:YodaoBot和OutfoxBot

搜搜蜘蛛: Sosospider

国外的搜索引擎蜘蛛

google蜘蛛: googlebot

yahoo蜘蛛:Yahoo! Slurp

alexa蜘蛛:ia_archiver

bing蜘蛛(MSN):msnbot

文章来源 于网络!

posted @ 2011-03-09 14:21  web_Designer  阅读(414)  评论(0)    收藏  举报