Back

Information About Search Engine Robots and the Robots.txt File

A robot is a program that automatically traverses the Web's hypertext structure by retrieving a document, and recursively retrieving all documents that are referenced. Some people call them Crawlers, or Spiders.  Search engines then search through its database of HTML documents gathered by their robot.

The Robots.txt file
Search engines will look in your root domain for a special file named "robots.txt". The file tells the robot which files it may check. The robots.txt file has a special format.

Note that the robots.txt file should be created in Unix line ender mode. Most good text editors will have a Unix mode or your FTP client *should* do the conversion for you. Do not use an HTML editor that does not specifically have a text mode to create a robots.txt file.

Here are the sections of the robots.txt file you need to know about:

User-agent
The User-agent line specifies the robot. For example:

User-agent: googlebot

You may also use the wildcard charcter "*" to specify all robots:

User-agent: *

You can find user agent names in your own logs by checking for requests to robots.txt. Most major search engines have short names for their spiders.

Disallow
The second part of a record consists of Disallow: directive lines. These lines specify files and/or directories. For example, the following line instructs spiders that it can not download email.htm:

Disallow: email.htm

You may also specify directories:

Disallow: /cgi-bin/

This will block spiders from your cgi-bin directory.

There is a wildcard nature to the Disallow directive. The standard dictates that /bob would disallow /bob.html and /bob/indes.html (both the file bob and files in the bob directory will not be indexed).

If you leave the Disallow line blank, it indicates that ALL files may be retrieved. At least one disallow line must be present for each User-agent directive to be correct. A completely empty Robots.txt file is the same as if it were not present.

White Space & Comments
Any line in the robots.txt that begins with # is considered to be a comment only. The standard allows for comments at the end of directive lines, but this is really bad style:

Disallow: tom #comment

Some spider will not interpret the above line correctly and instead will attempt to disallow "tom#comment". The moral is to place comments on lines by themselves.

White space at the beginning of a line is allowed, but not recommended.

    Disallow: tom #comment

Examples
The following allows all robots to visit all files because the wildcard "*" specifies all robots.

User-agent: *
Disallow:

This one keeps all robots out.

User-agent: *
Disallow: /

The next one bars all robots from the cgi-bin and images directories:

User-agent: *
Disallow: /cgi-bin/
Disallow: /images/

This one bans Roverdog from all files on the server:

User-agent: Roverdog
Disallow: /

This one bans keeps googlebot from getting at the cheese.htm file:

User-agent: googlebot
Disallow: cheese.htm

Back


Make a Comment on this Article

Your Name:
Comment: