是针对哪个搜索引擎蜘蛛。这里的*代表搜索引擎,*是通配符。
Allow
定义的是允许蜘蛛抓取某个栏目或文件
Allow:/cgi-bin/
这里定义的是允许访问cgi-bin目录
Allow:/* .htm$
允许访问以“.htm”为后缀的URL,$指的是匹配行结束符,*指的是匹配任何字符。
Disallow:/admin/
这里定义是禁止抓取admin目录
Disallow:/cgi-bin/*.htm
禁止抓取/cgi-bin/目录下的所有以“.htm”为后缀的URL
Disallow:/*?*
禁止抓取网站中所有包含问号“?”的网址
sitemap:URL全称(包含http://部分)
是告诉搜索引擎蜘蛛这个页面是网站地图。
robots.txt文件主要是限制整个站点或者目录的蜘蛛访问情况,而robots meta标签主要是针对某个具体的页面。
如:<meta name=“robots”content=“index,follow”>
robots meta标签语法
name=“robots”表示所有的搜索引擎,可以针对某个具体搜索引擎写为name=“Baiduspider”
content部分有四个指令,以英文逗号隔开
index指令告诉蜘蛛可以抓取该页面
follow指令表示蜘蛛可以爬行该页面上的链接
共有四种组合:
<meta name=“robots”content=“index,follow”>
<meta name=“robots”content=“noindex,follow”>
<meta name=“robots”content=“index,nofollow”>
<meta name=“robots”content=“noindex,nofollow”>
特殊写法:
<meta name=“robots”content=“index,follow”>可以写成<meta name=“robots”content=“all”>
<meta name=“robots”content=“noindex,nofollow”>可以写成<meta name=“robots”content=“none”>