<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>最优良人 &#187; robots</title>
	<atom:link href="http://www.zui88.com/view-tag/robots/feed" rel="self" type="application/rss+xml" />
	<link>http://www.zui88.com/blog</link>
	<description>中山php&#124;最优网络</description>
	<lastBuildDate>Mon, 13 May 2013 04:56:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
		<item>
		<title>robots.txt文件的规则以及限制目录带不带斜杠的区别</title>
		<link>http://www.zui88.com/blog/view-250.html</link>
		<comments>http://www.zui88.com/blog/view-250.html#comments</comments>
		<pubDate>Sat, 03 Sep 2011 02:11:43 +0000</pubDate>
		<dc:creator>lin</dc:creator>
				<category><![CDATA[搜索优化]]></category>
		<category><![CDATA[robots]]></category>
		<category><![CDATA[seo]]></category>

		<guid isPermaLink="false">http://www.zui88.com/blog/?p=250</guid>
		<description><![CDATA[一个网站的robots文件对于做seo是至关重要的，它可以限制搜索引擎蜘蛛抓取不该收录的目录或者页面，避免资源的浪费，它的规则主要有以下几点： 1) User-Agent键 后面的内容对应的是各个具体的搜索引擎爬行器的名称。如百度是Baiduspider，谷歌是Googlebot。 一般我们这样写： User-Agent: * 表示允许所有搜索引擎蜘蛛来爬行抓取。如果只想让某一个搜索引擎蜘蛛来爬行，在后面列出名字即可。如果是多个，则重复写。 注意：User-Agent:后面要有一个空格。 在robots.txt中，键后面加：号，后面必有一个空格，和值相区分开。 2)Disallow键 该键用来说明不允许搜索引擎蜘蛛抓取的URL路径。 例如：Disallow: /index.php 禁止网站index.php文件 Allow键 该键说明允许搜索引擎蜘蛛爬行的URL路径 例如：Allow: /index.php 允许网站的index.php 通配符* 代表任意多个字符 例如：Disallow: /*.jpg 网站所有的jpg文件被禁止了。 结束符$ 表示以前面字符结束的url。 例如：Disallow: /?$ 网站所有以?结尾的文件被禁止。 应该注意的是： 1，在"/robots.txt"文件中，至少要有一条Disallow记录,允许收录优先级要高于禁止收录,如 User-agent: * Allow: /a/b.htm Disallow: /a/ 则a目录下b.htm可以访问，其他禁止 2，注意路径后面加斜杠和不加斜杠的区别 如果目录后边带斜杠，那么访问不带斜杠的地址时还是可以访问目录首页，如果想屏蔽掉整个目录，建议不带斜杠 Allow或Disallow的值 URL 匹配结果 /tmp /tmp yes /tmp /tmp.html yes /tmp /tmp/a.html yes /tmp/ /tmp [...]]]></description>
			<content:encoded><![CDATA[<p>一个网站的robots文件对于做seo是至关重要的，它可以限制搜索引擎蜘蛛抓取不该收录的目录或者页面，避免资源的浪费，它的规则主要有以下几点：</p>
<p>1) User-Agent键</p>
<p>后面的内容对应的是各个具体的搜索引擎爬行器的名称。如百度是Baiduspider，谷歌是Googlebot。</p>
<p>一般我们这样写：</p>
<p>User-Agent: *</p>
<p>表示允许所有搜索引擎蜘蛛来爬行抓取。如果只想让某一个搜索引擎蜘蛛来爬行，在后面列出名字即可。如果是多个，则重复写。</p>
<p>注意：User-Agent:后面要有一个空格。</p>
<p>在robots.txt中，键后面加：号，后面必有一个空格，和值相区分开。</p>
<p>2)Disallow键</p>
<p>该键用来说明不允许搜索引擎蜘蛛抓取的URL路径。</p>
<p>例如：Disallow: /index.php 禁止网站index.php文件</p>
<p>Allow键</p>
<p>该键说明允许搜索引擎蜘蛛爬行的URL路径</p>
<p>例如：Allow: /index.php 允许网站的index.php</p>
<p>通配符*</p>
<p>代表任意多个字符</p>
<p>例如：Disallow: /*.jpg 网站所有的jpg文件被禁止了。</p>
<p>结束符$</p>
<p>表示以前面字符结束的url。</p>
<p>例如：Disallow: /?$ 网站所有以?结尾的文件被禁止。</p>
<p>应该注意的是：</p>
<p>1，在"/robots.txt"文件中，至少要有一条Disallow记录,允许收录优先级要高于禁止收录,如<br />
User-agent: *<br />
Allow: /a/b.htm<br />
Disallow: /a/<br />
则a目录下b.htm可以访问，其他禁止</p>
<p>2，注意路径后面加斜杠和不加斜杠的区别<br />
如果目录后边带斜杠，那么访问不带斜杠的地址时还是可以访问目录首页，如果想屏蔽掉整个目录，建议不带斜杠</p>
<table border="1" cellspacing="1" cellpadding="3" width="50%" align="center">
<tbody>
<tr>
<td width="40%" align="left">Allow或Disallow的值</td>
<td width="40%" align="left">URL</td>
<td width="20%" align="left">匹配结果</td>
</tr>
<tr>
<td width="40%" align="left">/tmp</td>
<td width="40%" align="left">/tmp</td>
<td width="20%" align="left">yes</td>
</tr>
<tr>
<td width="40%" align="left">/tmp</td>
<td width="40%" align="left">/tmp.html</td>
<td width="20%" align="left">yes</td>
</tr>
<tr>
<td width="40%" align="left">/tmp</td>
<td width="40%" align="left">/tmp/a.html</td>
<td width="20%" align="left">yes</td>
</tr>
<tr>
<td width="40%" align="left">/tmp/</td>
<td width="40%" align="left">/tmp</td>
<td width="20%" align="left">no</td>
</tr>
<tr>
<td width="40%" align="left">/tmp/</td>
<td width="40%" align="left">/tmphoho</td>
<td width="20%" align="left">no</td>
</tr>
<tr>
<td width="40%" align="left">/tmp/</td>
<td width="40%" align="left">/tmp/a.html</td>
<td width="20%" align="left">yes</td>
</tr>
<tr>
<td height="20"></td>
</tr>
<tr>
<td width="40%" align="left">/Hello*</td>
<td width="40%" align="left">/Hello.html</td>
<td width="20%" align="left">yes</td>
</tr>
<tr>
<td width="40%" align="left">/He*lo</td>
<td width="40%" align="left">/Hello,lolo</td>
<td width="20%" align="left">yes</td>
</tr>
<tr>
<td width="40%" align="left">/Heap*lo</td>
<td width="40%" align="left">/Hello,lolo</td>
<td width="20%" align="left">no</td>
</tr>
<tr>
<td width="40%" align="left">html$</td>
<td width="40%" align="left">/tmpa.html</td>
<td width="20%" align="left">yes</td>
</tr>
<tr>
<td width="40%" align="left">/a.html$</td>
<td width="40%" align="left">/a.html</td>
<td width="20%" align="left">yes</td>
</tr>
<tr>
<td width="40%" align="left">htm$</td>
<td width="40%" align="left">/a.html</td>
<td width="20%" align="left">no</td>
</tr>
</tbody>
</table>
<p>&nbsp;<br />
3，robots文件只有放在根目录才有效，放在子目录没效。</p>
<p>4，robots.txt文件用法举例</p>
<table border="1" cellspacing="1" cellpadding="3" width="85%" align="center">
<tbody>
<tr>
<td width="76%"><strong>例1.</strong> <strong>禁止所有搜索引擎访问网站的任何部分</strong></td>
<td width="24%"><em>User-agent: *<br />
Disallow: /</em></td>
</tr>
<tr>
<td><strong>例2.</strong> <strong>允许所有的robot访问</strong><br />
(或者也可以建一个空文件 “/robots.txt”)</td>
<td><em>User-agent: *<br />
Disallow: </em><br />
或者<br />
<em>User-agent: *<br />
Allow: /</em></td>
</tr>
<tr>
<td><strong>例3. 仅禁止Baiduspider访问您的网站</strong></td>
<td><em>User-agent: Baiduspider<br />
Disallow: /</em></td>
</tr>
<tr>
<td><strong>例4. 仅允许Baiduspider访问您的网站</strong></td>
<td><em>User-agent: Baiduspider<br />
Disallow:</em>&nbsp;</p>
<p><em>User-agent: *<br />
Disallow: /</em></td>
</tr>
<tr>
<td><strong>例5. 禁止spider访问特定目录</strong><br />
在这个例子中，该网站有三个目录对搜索引擎的访问做了限制，即robot不会访问这三个目录。需要注意的是对每一个目录必须分开声明，而不能写成 “Disallow: /cgi-bin/ /tmp/”。</td>
<td><em>User-agent: *<br />
Disallow: /cgi-bin/<br />
Disallow: /tmp/<br />
Disallow: /~joe/</em></td>
</tr>
<tr>
<td><strong>例6. 允许访问特定目录中的部分url</strong></td>
<td><em>User-agent: *<br />
Allow: /cgi-bin/see<br />
Allow: /tmp/hi<br />
Allow: /~joe/look<br />
Disallow: /cgi-bin/<br />
Disallow: /tmp/<br />
Disallow: /~joe/</em></td>
</tr>
<tr>
<td><strong>例7. 使用”*”限制访问url</strong><br />
禁止访问/cgi-bin/目录下的所有以”.htm”为后缀的URL(包含子目录)。</td>
<td><em>User-agent: *<br />
Disallow: /cgi-bin/*.htm<br />
</em></td>
</tr>
<tr>
<td><strong>例8. 使用”$”限制访问url</strong><br />
仅允许访问以”.htm”为后缀的URL。</td>
<td><em>User-agent: *<br />
Allow: .htm$<br />
Disallow: /</em></td>
</tr>
<tr>
<td><strong>例9. 禁止访问网站中所有的动态页面</strong></td>
<td><em>User-agent: *<br />
Disallow: /*?*</em></td>
</tr>
<tr>
<td><strong>例10. 禁止Baiduspider抓取网站上所有图片</strong><br />
仅允许抓取网页，禁止抓取任何图片。</td>
<td><em>User-agent: Baiduspider<br />
Disallow: .jpg$<br />
Disallow: .jpeg$<br />
Disallow: .gif$<br />
Disallow: .png$<br />
Disallow: .bmp$</em></td>
</tr>
<tr>
<td><strong>例11. 仅允许Baiduspider抓取网页和.gif格式图片</strong><br />
允许抓取网页和gif格式图片，不允许抓取其他格式图片</td>
<td><em>User-agent: Baiduspider<br />
Allow: .gif$<br />
Disallow: .jpg$<br />
Disallow: .jpeg$<br />
Disallow: .png$<br />
Disallow: .bmp$</em></td>
</tr>
<tr>
<td><strong>例12. 仅禁止Baiduspider抓取.jpg格式图片</strong></td>
<td><em>User-agent: Baiduspider<br />
Disallow: .jpg$</em></td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zui88.com/blog/view-250.html/feed</wfw:commentRss>
		<slash:comments>349</slash:comments>
		</item>
	</channel>
</rss>
