sections.html revision dd97a1ae529a4e543d3d24c8e25931dacb053c4f
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde<html><head>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde<title>How Directory, Location and Files sections work</title>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde</head>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde<BODY
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde BGCOLOR="#FFFFFF"
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde TEXT="#000000"
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde LINK="#0000FF"
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde VLINK="#000080"
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde ALINK="#FF0000"
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde<!--#include virtual="header.html" -->
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde<h1 ALIGN="CENTER">How Directory, Location and Files sections work</h1>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram HegdeThe sections <a
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegdehref="mod/core.html#directory"><code>&lt;Directory&gt;</code></a>, <a
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegdehref="mod/core.html#location"><code>&lt;Location&gt;</code></a> and <a
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegdehref="mod/core.html#files"><code>&lt;Files&gt;</code></a> can contain
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegdedirectives which only apply to specified directories, URLs or files
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayasesrespectively. Also htaccess files can be used inside a directory to
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegdeapply directives to that directory. This document explains how these
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegdedifferent sections differ and how they relate to each other when
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram HegdeApache decides which directives apply for a particular directory or
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegderequest URL.
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde<h2>Directives allowed in the sections</h2>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram HegdeEverything that is syntactically allowed in
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde<code>&lt;Directory&gt;</code> is also allowed in
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde<code>&lt;Location&gt;</code> (except a sub-<code>&lt;Files&gt;</code>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegdesection, but the code doesn't test for that, Lars has an open bug
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegdereport on that). Semantically however some things, and the most
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegdenotable is AllowOverrides, make no sense in
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde<code>&lt;Location&gt;</code>. The same for
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde<code>&lt;Files&gt;</code> -- syntactically everything is fine, but
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegdesemantically some things are different.
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde<h2>How the sections are merged</h2>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram HegdeThe order of merging is:
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde<ol>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde
c94adbf911e89a6f97faa6b966bc20f795e2f959Frank Van Der Linden<li>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde <code>&lt;Directory&gt;</code> (except regular expressions) and
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde .htaccess done simultaneously (with .htaccess overriding
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases <code>&lt;Directory&gt;</code>)
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde</li>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde<li>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde <code>&lt;DirectoryMatch&gt;</code>, and
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde <code>&lt;Directory&gt;</code> with regular expressions
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde</li>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde <li><code>&lt;Files&gt;</code> and <code>&lt;FilesMatch&gt;</code> done simultaneously
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde </li>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde <li><code>&lt;Location&gt;</code> and <code>&lt;LocationMatch&gt;</code> done simultaneously
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde </li>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde</ol>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram HegdeApart from <code>&lt;Directory&gt;</code>, each group is processed in
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegdethe order that they appear in the configuration
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegdefiles. <code>&lt;Directory&gt;</code> (group 1 above) is processed in
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegdethe order shortest directory component to longest. If multiple
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde<code>&lt;Directory&gt;</code> sections apply to the same directory
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegdethey they are processed in the configuration file order. The
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegdeconfiguration files are read in the order httpd.conf, srm.conf and
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegdeaccess.conf. Configurations included via the <code>Include</code>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegdedirective will be treated as if they where inside the including file
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegdeat the location of the <code>Include</code> directive.
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde<p>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram HegdeSections inside <code>&lt;VirtualHost&gt;</code> sections are applied
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde<i>after</i> the corresponding sections outside the virtual host
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegdedefinition. This allows virtual hosts to override the main server
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegdeconfiguration. (Note: this only works correctly from 1.2.2 and 1.3a2
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegdeonwards. Before those releases sections inside virtual hosts were
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegdeapplied <i>before</i> the main server).
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde<h2>Notes about using sections</h2>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram HegdeThe general guidelines are:
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde<p>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde<ul>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde<li>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde If you are attempting to match objects at the filesystem level
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde then you must use <code>&lt;Directory&gt;</code> and/or
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde <code>&lt;Files&gt;</code>.
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde</li>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde<li>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde If you are attempting to match objects at the URL level then you
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde must use <code>&lt;Location&gt;</code>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde</li>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde</ul>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram HegdeBut a notable exception is:
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde<ul>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde<li>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde proxy control is done via <code>&lt;Directory&gt;</code>. This is
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde a legacy mistake because the proxy existed prior to
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde <code>&lt;Location&gt;</code>. A future version of the config
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde language should probably switch this to
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde <code>&lt;Location&gt;</code>.
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde</li>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde</ul>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram HegdeNote also that modifying .htaccess parsing during Location doesn't do
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegdeanything because .htaccess parsing has already occured.
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde<p>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram HegdeAnother note:
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde<p>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde<ul>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde<li>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde There is actually a
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde <code>&lt;Location&gt;</code>/<code>&lt;LocationMatch&gt;</code>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde sequence performed just before the name translation phase (where
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde <code>Aliases</code> and <code>DocumentRoots</code> are used to
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde map URLs to filenames). The results of this sequence are
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde completely thrown away after the translation has completed.
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde</li>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde</ul>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde<!--#include virtual="footer.html" -->
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde</body></html>
3a634bfc9a31448c742688c603d3e76b83b041a0Vikram Hegde