什么是robots.txt?

| No Comments | No TrackBacks

robots.txt 文件对抓取网络的搜索引擎漫游器(称为漫游器)进行限制。这些漫游器是自动的,在其访问网页前会查看是否存在阻止其访问特定网页的 robots.txt 文件。

如何创建 robots.txt 文件?

可以在任何文本编辑器中创建此文件。该文件应为 ASCII 编码的文本文件,而非 HTML 文件。文件名应使用小写字母。

语法
最简单的 robots.txt 文件使用两条规则:

  • User-Agent:适用下列规则的漫游器
  • Disallow:要拦截的网页

这两行被视为文件中的一个条目。您可根据需要包含任意多个条目。您可在一个条目中包含多个 Disallow 行和多个 User-Agent。

应在 User-Agent 行中列出什么内容?
user-agent 是特定的搜索引擎漫游器。网络漫游器数据库列出了许多常用漫游器。您可设置应用于特定漫游器的条目(通过列示名称)或设置为应用于所有漫游器(通过列示星号)。应用于所有漫游器的条目应与下列条目类似:

User-Agent:*

Google 使用多种不同漫游器(用户代理)。用于网络搜索的漫游器是 Googlebot。Googlebot-Mobile 和 Googlebot-Image 等其他漫游器遵循您为 Googlebot 设置的规则,您还可为这些特定漫游器设置附加规则。

应在 Disallow 行中列出什么内容?
Disallow 行列出了您要拦截的网页。您可列出具体网址或网址模式。条目应以正斜杠开头 (/)。

  • 要拦截整个网站,请使用正斜扛。
    Disallow:/
  • 要拦截目录及其中的所有内容,请在目录名后添加正斜扛。
    Disallow:/private_directory/
  • 要拦截网页,请列出该网页。
    Disallow:/private_file.html

网址区分大小写。例如,Disallow: /private_file.html 将拦截 http://www.example.com/private_file.html,但允许 http://www.example.com/Private_File.html

更多内容请访问:http://www.google.com/support/webmasters

 

仅当您的网站包含不希望搜索引擎编入索引的内容时,才需要使用 robots.txt 文件。如果您希望搜索引擎将网站上的所有内容编入索引,则不需要 robots.txt 文件(甚至连空文件也不需要)。

示例:

------------------------------------------------------------------------------------------------------------------------------------------

#
# robots.txt for NetMao Movie
# Version 2.0.x
#

User-agent: *
Disallow: /admin/
Disallow: /inc/
Disallow: /html/
Disallow: /templates/

No TrackBacks

TrackBack URL: http://www.wujianrong.com/mt-tb.cgi/955

Leave a comment

About this Entry

This page contains a single entry by kevinwu published on August 19, 2006 1:01 AM.

如何提高网站排名? was the previous entry in this blog.

Building your very own web2.0 layout is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.