Chapter 9. Delegated control

Table of Contents
9.1. Customising only part of a web site
9.2. Using Access Files

<Directory>. Applying a specialised set of commands just to a subdirectory of a web site from the httpd.conf file.

Include. Splitting the main configuration file into components.

AccessFileName. Nominating a filename to handle control from the directory itself.

AddDescription. A commonly used command in the delegated configuration files to set the Description column in automatic indexes.

AllowOverride. Controlling what can be delegated

9.1. Customising only part of a web site

The user directory example was the first where we were passing control outside our tidy server root. It may well be that we want a different configuration for these, relatively uncontrolled, areas.

There are a number of aspects to this. You must decide what defaults you want passed to these areas and what you want absolutely fixed. You also need to know how to override the defaults where permitted.

We will start by noting how to change settings from within the httpd.conf file for a directory tree. In our current configuration file the directory index file name is index.html. Suppose for a subdirectory of one of our web sites we wanted to change it to be main.html. How would we do that?

<VirtualHost *>
ServerName	www.dept.cam.ac.uk
DocumentRoot	/srv/www/WWW
CustomLog	/var/log/apache2/www.log clf

<Directory /srv/www/WWW/bestiary>
  DirectoryIndex main.html 
</Directory>

</VirtualHost>

The <Directory dir> ... </Directory> identifies a series of commands which should override or enhance the general settings for a specific subdirectory, /var/www/WWW/bestiary in the example given in the figure.

In the case of commands we have met, it is easy to imagine simply issuing them again within a <Directory> block to override the previous settings. But what about turning features on or off? A common example is to turn on or off the automatic generation of indexes.

At the moment we can see the index of the games directory in the www.dept.cam.ac.uk web site.

We can turn indexing off with the Options command as follows.

<VirtualHost *>
ServerName	www.dept.cam.ac.uk
DocumentRoot	/srv/www/WWW
CustomLog	/var/log/apache2/www.log clf

<Directory /srv/www/WWW/bestiary>
  DirectoryIndex main.html 
</Directory>

<Directory /srv/www/WWW/games>
  Options -Indexes
</Directory>

</VirtualHost>

And any future attempt to index games gives a 403, Forbidden, error.