(function(a,e,f,g,b,c,d){a.GoogleAnalyticsObject=b;a[b]=a[b]||function(){(a[b].q=a[b].q||[]).push(arguments)};a[b].l=1*new Date;c=e.createElement(f);d=e.getElementsByTagName(f)[0];c.async=1;c.src=g;d.parentNode.insertBefore(c,d)})(window,document,"script","https://www.google-analytics.com/analytics.js","ga");ga("create","UA-732153-7","auto",{allowLinker:!0,siteSpeedSampleRate:10});ga("set","transport","beacon");ga("set","anonymizeIp",!0);ga("require","linker"); ga("linker:autoLink","askapache.com askapache.net htaccess.io htaccesselite.com askapache.info htaccess.guru".split(" "),!0);ga("send","pageview"); vlink="#000080" alink="#FF0000">

Apache HTTP Server Version 1.3

Is this the version you want? For more recent versions, check our documentation index.

How Directory, Location and Files sections work

The sections <Directory>, <Location> and <Files> can contain directives which only apply to specified directories, URLs or files respectively. Also htaccess files can be used inside a directory to apply directives to that directory. This document explains how these different sections differ and how they relate to each other when Apache decides which directives apply for a particular directory or request URL.

Directives allowed in the sections

Everything that is syntactically allowed in <Directory> is also allowed in <Location> (except a sub-<Files> section). Semantically, however some things, most notably AllowOverride and the two options FollowSymLinks and SymLinksIfOwnerMatch, make no sense in <Location>, <LocationMatch> or <DirectoryMatch>. The same for <Files> -- syntactically everything is fine, but semantically some things are different.

How the sections are merged

The order of merging is:

  1. <Directory> (except regular expressions) and .htaccess done simultaneously (with .htaccess, if allowed, overriding <Directory>)
  2. <DirectoryMatch>, and <Directory> with regular expressions
  3. <Files> and <FilesMatch> done simultaneously
  4. <Location> and <LocationMatch> done simultaneously

Apart from <Directory>, each group is processed in the order that they appear in the configuration files. <Directory> (group 1 above) is processed in the order shortest directory component to longest. If multiple <Directory> sections apply to the same directory they are processed in the configuration file order. The configuration files are read in the order httpd.conf, srm.conf and access.conf. Configurations included via the Include directive will be treated as if they were inside the including file at the location of the Include directive.

Sections inside <VirtualHost> sections are applied after the corresponding sections outside the virtual host definition. This allows virtual hosts to override the main server configuration. (Note: this only works correctly from 1.2.2 and 1.3a2 onwards. Before those releases sections inside virtual hosts were applied before the main server).

Later sections override earlier ones.

Notes about using sections

The general guidelines are:

But a notable exception is:

Note about .htaccess parsing:

<Location> and symbolic links:

<Files> and Options:

Another note:

Apache HTTP Server