sections.html revision 57d0156f7bbd9ea3a72342cf9912aba61d118702
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm <meta name="generator" content="HTML Tidy, see www.w3.org" />
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm <title>How Directory, Location and Files sections work</title>
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm <!-- Background white, links blue (unvisited), navy (visited), red (active) -->
9dc68827cbd515262ecb8d5ae8547d9e82c72e00Jon A. Cruz <body bgcolor="#FFFFFF" text="#000000" link="#0000FF"
701b7755a8684f12de91c2a76effa19f50652838joncruz <!--#include virtual="header.html" -->
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm <h1 align="CENTER">How Directory, Location and Files sections
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm href="mod/core.html#directory"><code><Directory></code></a>,
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm href="mod/core.html#location"><code><Location></code></a>
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm href="mod/core.html#files"><code><Files></code></a> can
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm contain directives which only apply to specified directories,
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm URLs or files respectively. Also htaccess files can be used
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm inside a directory to apply directives to that directory. This
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm document explains how these different sections differ and how
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm they relate to each other when Apache decides which directives
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm apply for a particular directory or request URL.</p>
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm <p>Everything that is syntactically allowed in
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm sub-<code><Files></code> section). Semantically, however
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm some things, most notably <code>AllowOverride</code> and the
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm <code><Files></code> -- syntactically everything is fine,
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm but semantically some things are different.</p>
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm expressions) and .htaccess done simultaneously (with
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm .htaccess, if allowed, overriding
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm <code><Directory></code> with regular expressions</li>
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm <code><FilesMatch></code> done simultaneously</li>
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm <code><LocationMatch></code> done simultaneously</li>
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm <p>Apart from <code><Directory></code>, each group is
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm processed in the order that they appear in the configuration
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm files. <code><Directory></code> (group 1 above) is
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm processed in the order shortest directory component to longest.
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm If multiple <code><Directory></code> sections apply to
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm the same directory they they are processed in the configuration
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm file order. The configuration files are read in the order
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm httpd.conf, srm.conf and access.conf. Configurations included
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm via the <code>Include</code> directive will be treated as if
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm they were inside the including file at the location of the
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm <p>Sections inside <code><VirtualHost></code> sections
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm are applied <em>after</em> the corresponding sections outside
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm the virtual host definition. This allows virtual hosts to
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm override the main server configuration.</p>
ca4d1d8972d64c1d1bfdd4b09d31f7b372074940Jon A. Cruz <li>If you are attempting to match objects at the filesystem
7ec62a28f0a00295169b784ae59eda6c11b906bdjoncruz level then you must use <code><Directory></code> and/or
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm <li>If you are attempting to match objects at the URL level
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm <li>proxy control is done via <code><Directory></code>.
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm This is a legacy mistake because the proxy existed prior to
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm <code><Location></code>. A future version of the config
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm language should probably switch this to
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm <li>Modifying .htaccess parsing during Location doesn't do
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm anything because .htaccess parsing has already occurred.</li>
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm <p><code><Location></code> and symbolic links:</p>
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm SymLinksIfOwnerMatch</code>" inside a
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm <code><DirectoryMatch></code> section (the options are
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm simply ignored). Using the options in question is only
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm possible inside a <code><Directory></code> section (or
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm <p><code><Files></code> and <code>Options</code>:</p>
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm <li>Apache won't check for it, but using an
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm <li>There is actually a
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm <code><Location></code>/<code><LocationMatch></code>
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm sequence performed just before the name translation phase
276cb9f2911717ca435c14fc45a7291f68555388tavmjong (where <code>Aliases</code> and <code>DocumentRoots</code>
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm are used to map URLs to filenames). The results of this
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm sequence are completely thrown away after the translation has
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm completed.</li>
da58597f9f9ecb17c4f545c4483a844a363bcc27pjrm <!--#include virtual="footer.html" -->