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