Page 47 - Open Soource Technologies 304.indd
P. 47

Open Source Technologies



                   Notes         Compatibility: This entry contains information about which versions of Apache support the
                                 directive.
                                 Override: Apache directives belong to different categories. The override field is used to specify
                                 which  directive  categories  can  appear  in.htaccess  per-directory  configuration  files.  A  brief
                                 explanation of the directive follows these entries in the documentation, and a reference to related
                                 directives or documentation may appear at the end.
                                 4.2.2 Containers

                                 Directive containers, also called sections, limit the scope for which directives apply. If directives
                                 are not inside a container, they belong to the default server scope (server config) and apply to
                                 the server as a whole.

                                 These are the default Apache directive containers:

                                 <VirtualHost>? A VirtualHost directive specifies a virtual server. Apache enables you to host
                                 different Web sites with a single Apache installation. Directives inside this container apply to a
                                 particular Web site. This directive accepts a domain name or IP address and an optional port as
                                 arguments. You will learn more about virtual hosts in Hour 22, “Apache Performance Tuning
                                 and Virtual Hosting.”

                                 <Directory>, <DirectoryMatch>? These containers allow directives to apply to a certain directory
                                 or group of directories in the file system. Directory containers take a directory or directory pattern
                                 argument. Enclosed directives apply to the specified directories and their subdirectories. The
                                 DirectoryMatch container allows regular expression patterns to be specified as an argument. For
                                 example, the following allows a match of all subdirectories of the www directory that are made
                                 up of four numbers, such as a directory named after a year and month (0902 for September 2010):
                                           <DirectoryMatch “^/www/.*/[0-9]{4}”>
                                 <Location>, <LocationMatch>? These containers allow directives to apply to certain requested
                                 URLs or URL patterns. They are similar to their Directory counterparts. LocationMatch takes a
                                 regular expression as an argument. For example, the following matches directories containing
                                 either “/my/data” or “/your/data”:
                                 <LocationMatch “/(my|your)/data”>

                                 <Files>, <FilesMatch>? Similar to Directory and Location containers, Files sections allow directives
                                 to apply to certain files or file patterns.
                                 Containers surround directives, as shown in Listing 1.

                                 Listing 1 Sample Container Directives:

                                    1.  <Directory “/some/directory”>
                                    2.  SomeDirective1

                                    3.  SomeDirective2
                                    4.  </Directory>

                                    5.  <Location “/downloads/*.html”>





        42                                LOVELY PROFESSIONAL UNIVERSITY
   42   43   44   45   46   47   48   49   50   51   52