Directive Containers Directive containers, also called sections, limit the scope to which directives apply. If directives are not inside a container, they belong to the default server scope (server config), applying to the server as a whole. <Directory "/usr/local/apache/htdocs"> ... </Directory> <Location "/downloads/*.html"> ... </Location> <FilesMatch "\.(gif|jpg)"> ... </FilesMatch> Default Apache Directive Containers The following directive containers are the default containers used in Apache configuration files. <VirtualHost> A VirtualHost directive specifies a virtual server. Apache enables you to host different websites with a single Apache installation, as described in Chapter 5. <Directory> and <DirectoryMatch> These containers apply directives to a certain directory or group of directories in the file system. The DirectoryMatch container allows regular expression patterns to be used as arguments. <Location> and <LocationMatch> Applies directives to certain requested URLs or URL patterns. They are similar to Directory containers. <Files> and <FilesMatch> Similar to Directory and Location containers, Files sections apply directives to certain files or file patterns. These are not the only directive containers available. Modules, such as mod_proxy, may provide their own containers, as explained in Chapter 10. See also Chapter 8 for details on containers that limit access based on HTTP methods. Note Directory, Files, and Location sections can also take regular expression arguments by preceding them with a ~. Regular expressions are strings that describe or match a set of strings, according to certain syntax rules. For example, the following regular expression will match all requests asking for an image file with a .jpg or .gif extension: <Files ~ "\.(gif|jpg)">. However, the DirectoryMatch, LocationMatch, and FilesMatch directives are preferred for clarity. You can learn more about regular expressions at http://en.wikipedia.org/wiki/Regular_expression. Directive Containers for Conditional Evaluation Apache provides support for conditional containers. Directives enclosed in these containers will be processed only if certain conditions are met. <IfDefine> Directives in this container will be processed if a specific command-line switch is passed to the Apache executable. In the following example, the command-line switch should be DSSL. Similarly, you can negate the argument with a "!", as in <IfDefine !SSL>, if you want the directives to apply if the switch was not passed. <IfModule> Directives in an IfModule section will be processed only if the module passed as an argument is present in the web server. The default Apache configuration file includes such examples for different MPMs modules. For example, in the httpd.conf file, you would see <IfDefine SSL> LoadModule ssl_module modules/mod_ssl.so </IfDefine> And you would enable it at the command line like this: # httpd -DSSL |