Online Book Reader

Home Category

Running Linux, 5th Edition - Matthias Kalle Dalheimer [430]

By Root 1514 0
with icons representing various file types. Figure 5-2 shows an example of such an index.

Icons are assigned using the AddIcon directive, as seen here:

# Set up various icons for use with fancy indexes, by filename

# E.g., we use DocumentRoot/icons/movie.xbm for files ending

# in .mpg and .qt

AddIcon /icons/movie.xbm .mpg

AddIcon /icons/back.xbm ..

AddIcon /icons/menu.xbm ^^DIRECTORY^^

AddIcon /icons/blank.xbm ^^BLANKICON^^

DefaultIcon

/icons/unknown.xbm

The icon filenames (such as /icons/movie.xbm) are relative to DocumentRoot by default. (There are other ways to specify pathnames to documents and icons—for example, by using aliases. This is discussed later.) There is also an AddIconByType directive, which lets you specify an icon for a document based on the document's MIME type, and an AddIconByEncoding directive, which lets you specify an icon for a document based on the document's encoding (i.e., whether and how it is compressed).

You can also specify an icon to be used when none of the above matches. This is done with the DefaultIcon directive.

The optional ReadmeName and HeaderName directives specify the names of files to be included in the index generated by httpd:

ReadmeName README

HeaderName HEADER

Here, if the file README.html exists in the current directory, it will be appended to the index. The file README will be appended if README.html does not exist. Likewise, HEADER.html or HEADER will be included at the top of the index generated by httpd. You can use these files to describe the contents of a particular directory when an index is requested by the browser:

# Local access filename.

AccessFileName .htaccess

# Default MIME type for documents.

DefaultType text/plain

The AccessFileName directive specifies the name of the local configuration file for each directory. (This is described later in this chapter.) The DefaultType directive specifies the MIME type for documents not listed in mime.types.

The following lines specify directories for useful files:

# Set location of icons.

Alias

/icons/ /usr/local/html/icons/

# Set location of CGI binaries.

ScriptAlias

/cgi-bin/ /usr/local/httpd/cgi-bin/

The Alias directive specifies an alias for any of the files that would normally not be visible through the web server. Earlier, we used the AddIcon directive to set icon names using pathnames such as /icons/movie.xbm. Here, we specify that the pathname /icons/ should be translated to /usr/local/html/icons/. Therefore, the various icon files should be stored in the latter directory. You can use Alias to set aliases for other pathnames as well.

The ScriptAlias directive is similar, but it sets the actual location of CGI scripts on the system. Here, we wish to store scripts in the directory /usr/local/httpd/cgi-bin/. Any time a URL is used with a leading directory component of /cgi-bin/, it is translated into the actual directory name. More information on CGI and scripts is included in the book CGI Programming with Perl, by Scott Guelich, Shishir Gundavaram, and Gunther Birznieks (O'Reilly).

entries specify the options and attributes for a particular directory, as in the following:

# Set options for the cgi-bin script directory.

Options Indexes FollowSymLinks

Here, we specify that the CGI script directory should have the access options Indexes and FollowSymLinks. A number of access options are available. These include the following:

FollowSymLinks

Symbolic links in this directory should be followed to retrieve the documents to which they point. This option is not entirely safe to use on multiuser systems because it allows any user to create a link to some other file or directory (e.g., /etc/passwd). Use SymLinksIfOwnerMatch as a safer (but slightly slower) alternative.

SymLinksIfOwnerMatch

Symbolic links in this directory should be followed only if the target file or directory is owned by the same user ID as the link.

ExecCGI

Allow the execution of CGI scripts from this directory.

Indexes

Allow indexes

Return Main Page Previous Page Next Page

®Online Book Reader