
Chapter 6. Handling directories
There are two solutions to this issue. The first, and simplest, is to nominate a filename
(such as index.html) and instruct that if a directory is requested which contains a
file with this name then that file should be treated as the target of the request. This is
the approach we will follow in the Section called Using default documents.
The other approach is to give a listing of the directory’s contents, typically in HTML
format. We will cover this in the Section called Automatic indexing of directories.
Using default documents
Loading the module
We will add lines to the configuration file to load the module and to set up a default
file. Because we want this functionality for both websites we place the instruction
outside and before the virtual host sections.
LoadModule dir_module modules/mod_dir.so
DirectoryIndex index.html index.htm
Figure 6-2. httpd.conf: Using dir_module
Note that we have a new command DirectoryIndex which is the only additional
command provided by dir_module. It is passed a list of the defaults to use if the
directory is looked for. If a directory is requested then the web server will look for
index.html in the directory because that filename is the first argument to the com-
mand. If index.html is missing then the server will look for index.htm, the second
quoted name. If neither is present then the web server will give a not found error.
Remember the server must reload its configuration to pick up these new instructions.
Figure 6-3. / equivalent to /index.html
32
Comentarios a estos manuales