This section is from the "Practical mod_perl" book, by Stas Bekman and Eric Cholet. Also available from Amazon: Practical mod_perl
Scope: Can appear in server and virtual host configurations.
<Directory> and </Directory> are used to enclose a group of directives that will apply to only the named directory and its contents, including any subdirectories. Any directive that is allowed in a directory context (see the Apache documentation) may be used.
The path given in the <Directory> directive is either the full path to a directory, or a string containing wildcard characters (also called globs). In the latter case, ? matches any single character, * matches any sequence of characters, and [ ] matches character ranges. These are similar to the wildcards used by sh and similar shells. For example:
<Directory /home/httpd/docs/foo[1-2]> Options Indexes </Directory>
will match /home/httpd/docs/foo1 and /home/httpd/docs/foo2. None of the wildcards will match a / character. For example:
<Directory /home/httpd/docs> Options Indexes </Directory>
matches /home/httpd/docs and applies to all its subdirectories.
Matching a regular expression is done by using the <DirectoryMatch regex> ... </DirectoryMatch> or <Directory ~ regex> ... </Directory>syntax. For example:
<DirectoryMatch /home/www/.*/public> Options Indexes </DirectoryMatch>
will match /home/www/foo/public but not /home/www/foo/private. In a regular expression, .* matches any character (represented by .) zero or more times (represented by *). This is entirely different from the shell-style wildcards used by the <Directory> directive. They make it easy to apply a common configuration to a set of public directories. As regular expressions are more flexible than globs, this method provides more options to the experienced user.
If multiple (non-regular expression) <Directory>sections match the directory (or its parents) containing a document, the directives are applied in the order of the shortest match first, interspersed with the directives from any .htaccess files. Consider the following configuration:
<Directory /> AllowOverride None </Directory> <Directory /home/httpd/docs/> AllowOverride FileInfo </Directory>
Let us detail the steps Apache goes through when it receives a request for the file /home/httpd/docs/index.html:
Apply the directive AllowOverride None (disabling .htaccess files).
Apply the directive AllowOverride FileInfo for the directory /home/httpd/docs/ (which now enables .htaccess in /home/httpd/docs/ and its subdirectories).
Apply any directives in the group FileInfo, which control document types (AddEncoding, AddLanguage, AddType, etc.—see the Apache documentation for more information) found in /home/httpd/docs/.htaccess.
 
Continue to: