• robots


    引用:http://cn.idao114.com/zhinan/robots-txt-usage

    什么是robots.txt?Robots.txt的官方标准写法

    什么是robots.txt呢?Wordpress的robots.txt文件如何来写?

    其实它只是一个放在网站根目录内,并且记录了一些些文字的文本文件罢了。 但它是如何在网站的优化中起到作用的呢? 简单的说就是搜寻引擎会根据你的robots.txt的内容去[ 按表操作]。 哪些内容应该要被搜寻引擎所搜索到,哪些内容你觉得不应该被搜索,你可以设定好你的robots.txt档案全部都由robots.txt来做指挥。

    那我们应该如何设置robots.txt的内容呢? 以下说明请您参考

    所有的记录档的语法都是以 “:” 来做为一行, Field表示栏位的名称,而冒号后面接着对这栏位的值

    robots.txt档名必须是小写的,并且注意必须是文字档而非html格式,并且如果你是放在Linux/Unix的主机上的,档案的格式必须是遵循其格式撰写,你可以使用一些文字编译器编写,要注意格式就对了,主要的语法大概如下:

    User-Agent:后面的值表示是针对哪一个bot的抓取行为,例如:

    User-Agent: *
    表示针对所有的Robot抓取行为

    User-Agent: Slurp
    表示针对Yahoo Robot的抓取行为,Slurp是Yahoo! crawler的名称

    Disallow:表示在这个后面所写的值的网址字串所得到的所有网址都不接受bot抓取,例如:

    Disallow: /
    表示根目录下所有的网页和目录都不接受抓取

    Disallow: /news
    表示根目录下news延伸出来的所有目录和网页都不接受抓取,注意这个值的意义包括该字串所接得起来的所有可读取的网页和目录,所以Disallow: /news代表底下的连结都是不接受抓取的!!

    http://yourdomain.com/news/index

    http://yourdomain.com/newshistory/

    http://yourname.com/newstoday.html

    http://yourname.com/news.php

    也就是说,Disallow后面开始接的就是你的网域名称最后的那条反斜线为开始就对了 ,其他的撰写规格需要注意的,大概只有每一个描述请独立一行,其他没什么注意的了

    接下来举几个比较让人明了的例子:

    User-Agent: Googlebot
    Disallow: /mysite/test/
    Disallow: /mysite/cgi-bin/post.cgi?action=reply
    Disallow: /a

    在这个例子中底下的内容都会禁止被Google的bot抓取:

    http://adomain.com/mysite/test/index.html

    http://adomain.com/mysite/cgi-bin/post.cgi?action=reply&id=1

    http://adomain.com/mysite/cgi-bin/post.cgi?action=replytome

    http://adomain.com/abc.html

    而底下的内容依然会被Google的bot抓取:

    http://adomain.com/mysite/test.html

    http://adomain.com/mysite/cgi-bin/post.cgi?action=edit

    http://adomain.com/mysite/cgi-bin/post.cgi

    http://adomain.com/bbc.html

    最后你可以用allow做一个disallow的反向处理例如
    User-Agent: Googlebot
    Disallow: /cgi-bin/
    Allow: /cgi-bin/Ultimate.cgi
    Allow: /cgi-bin/forumdisplay.cgi

    在http://adomain.com/cgi-bin/ 下的所有目录和档案都会禁止被Google的bot抓取,除了http://adomain.com/cgi-bin/Ultimate.cgi 和http://adomain .com/cgi-bin/forumdisplay.cgi 这两个档案之外

    再例如:

    User-Agent: *
    Disallow: /cgi-bin/

    User-Agent: FreeFind
    Disallow:

    所有的搜寻引擎bot都不可以抓取http://adomain.com/cgi-bin/ 下的所有档案和目录,但是名叫FreeFind的bot例外,FreeFind robot可以抓取所有的档案和目录

    请注意几点差异

    Disallow: /
    表示全部禁止

    Disallow:
    表示没有禁止

    到这里要多注意的是

    1.建议两段的user-agent:之间请空一行

    2.后面写的URL是有分大小写的

    最后介绍[ * ] 代表所谓的万用字元表示,[ $ ] 代表所谓的结尾符号称为媒合符号, Googlebot 可解译一些模式媒合。 这是标准模式的延伸,但注意并不是全部的bot (漫游器) 都能适用

    若要拦截所包含问号(?)之URL的存取,您可以使用下列项目:
    User-agent:* Disallow:/*?*

    若要拦截以.asp结尾的URL,您可以使用下列项目:
    User-Agent:Googlebot Disallow:/*.asp$

    关于这个[ * ]和[ $ ]的问题,Google上有不错的解说,你可以参考这里Google如何检索我的网站

    OK,到这里为止,如果你的wordpress网站是放在根目录下面的,那么底下是我放在cocolike.com根目录下的建议适合WordPress使用的设定:

    User-Agent: *
    # disallow all files in these directories
    Disallow: /dh_
    Disallow: /cgi-bin/
    Disallow: /files/
    Disallow: /forum/
    Disallow: /pictures/
    Disallow: /usersguide/
    Disallow: /utilities/
    Disallow: /wp-admin/
    Disallow: /wp-includes/
    Disallow: /ela
    Disallow: /contact
    Disallow: /feed/
    Disallow: /trackback/
    Disallow: */feed$
    Disallow: */trackback$
    Disallow: *.htmlemail/
    Disallow: *.htmlprint/

    User-Agent: Googlebot
    # disallow all files ending with these extensions
    Disallow: /*.php$
    Disallow: /*.js$
    Disallow: /*.inc$
    Disallow: /*.css$
    Disallow: /*.gz$
    Disallow: /*.wmv$
    Disallow: /*.cgi$
    Disallow: /*.xhtml$

  • 相关阅读:
    原型模型
    单例模式
    C# 委托 delegate
    C#泛型
    客户端注册Cannot execute request on any known server解决
    SpringCloud 学习(二)-2 :Securing The Eureka Server
    SpringCloud 学习(二)-1 :服务注册与发现Eureka扩展
    解决网速慢时maven仓库访问慢
    SpringCloud 学习(二) :服务注册与发现Eureka
    SpringCloud版本问题
  • 原文地址:https://www.cnblogs.com/sode/p/2491435.html
Copyright © 2020-2023  润新知