-->
Previous | Table of Contents | Next |
In many cases, be it for consistency or just plain old security reasons, youll want to have the directory indexing engine just ignore certain types of files, such as emacs backup files or files beginning with a. (hidden files). The IndexIgnore directive allows you to specify the types of files to ignore when creating a directory index. The default setting is this:
IndexIgnore */.??* *~ *# */HEADER* */README* */RCS
This line might look cryptic, but its basically a space-separated list of patterns. The first pattern matches against any. file thats longer than three characters. This way, the link to the higher-up directory (..) can still work. The second (*~) and third (*#) patterns are common for matching old emacs backup files. The next patterns are to avoid listing the same files used for HeaderName and ReadmeName. The last (*/RCS) is given because many sites use RCS, a software package for revision control maintenance, which stores its extra (rather sensitive) information in RCS directories.
Finally, you get to two very interesting directives for controlling the last set of options regarding directory indexing. The first is AddDescription, which works similarly to AddIcon:
AddDescription description filename [filename]
For example,
AddDescription "My cat" /private/cat.gif
As elsewhere, filename can actually be a pattern, so you can have
AddDescription "An MPEG Movie Just For You!" *.mpg
Finally, you have the granddaddy of all options-setting directives, the smorgasbord of functionality controlIndexOptions. The syntax is simple:
IndexOptions option [option]
Table 36.2 lists the available options.
Option | Explanation |
---|---|
FancyIndexing | This option is the same as the separate FancyIndexing directive. (Sorry to confuse everyone, but backward compatibility demands bizarre things sometimes!) |
IconsAreLinks | If this option is set, the icon will be clickable as a link to whatever resource the entry its associated with links to. In other words, the icon becomes part of the hyperlink. |
ScanHTMLTitles | When given a listing for an HTML file, the server will open the HTML file and parse it to obtain the value of the <TITLE> field in the HTML document, if it exists. This can put a pretty heavy load on the server, because its a lot of disk accessing and some amount of CPU to extract the title from the HTML. Thus, its not recommended unless you know you have the capacity. |
SuppressDescription, SuppressLastModified, SuppressSize | These will suppress their respective fields (Description, Last Modified, and Size). Normally, each of those is a field in the output listings. |
By default, none of these IndexOptions is turned on. The options dont merge, which means that when youre setting these on a per-directory basis by using access.conf or .htaccess files, setting the options for a more specific directory requires resetting the complete options listing. For example, envision the following in your access configuration file:
<Directory /pub/docs/> IndexOptions ScanHTMLTitles </Directory> <Directory /pub/docs/others/> IndexOptions IconsAreLinks </Directory>
Directory listings done in or below the second directory, /pub/docs/others/, wouldnt have ScanHTMLTitles set. Why? Well, you figured administrators would need to be able to disable an option they had set globally in a specific directory. This was simpler than writing NOT logic into the options listings.
If you run into problems getting directory indexing to work, make sure that the settings you have for the Options directive in the access config files allow for directory indexing in that directory. Specifically, the Options directive must include Indexing. Whats more, if youre using .htaccess files to set things such as AddDescription or AddIcon, the AllowOverride directive must include FileInfo in its list of options.
Sites with many users sometimes prefer to be able to give their users access to managing their own parts of the Web tree in their own directories, using the URL semantics of
http://myhost.com/~user/
where ~user is actually an alias to a directory in the users home directory. This is different from the Alias directive, which could map only a particular pseudo-directory into an actual directory. In this case, you want ~user to map to something like /home/user/public_html. Because the number of users can be very high, some sort of macro is useful here. That macro is the UserDir directive.
With UserDir, you specify the subdirectory within the users home directories where they can put content, which is mapped to the ~user URL. So in other words, the default
UserDir public_html
will cause a request for
http://myhost.com/~dave/index.html
to cause a lookup for the UNIX file
/home/dave/public_html/index.html
presuming that /home/dave is Daves home directory.
Most of the functionality that distinguishes Apache from the competition has been implemented as modules to the Apache API. This has been extremely useful in allowing functionality to evolve separately from the rest of the server, and for allowing for performance tuning. The following sections cover that extra functionality in detail.
Previous | Table of Contents | Next |