]> granicus.if.org Git - apache/blob - docs/manual/sections.html.en
Rebuild transformations/translations
[apache] / docs / manual / sections.html.en
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
4         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5               This file is generated from xml source: DO NOT EDIT
6         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
7       -->
8 <title>Configuration Sections - Apache HTTP Server</title>
9 <link href="./style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
10 <link href="./style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
11 <link href="./style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
12 <link href="./images/favicon.ico" rel="shortcut icon" /></head>
13 <body id="manual-page"><div id="page-header">
14 <p class="menu"><a href="./mod/">Modules</a> | <a href="./mod/directives.html">Directives</a> | <a href="./faq/">FAQ</a> | <a href="./glossary.html">Glossary</a> | <a href="./sitemap.html">Sitemap</a></p>
15 <p class="apache">Apache HTTP Server Version 2.3</p>
16 <img alt="" src="./images/feather.gif" /></div>
17 <div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="./images/left.gif" /></a></div>
18 <div id="path">
19 <a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="./">Version 2.3</a></div><div id="page-content"><div id="preamble"><h1>Configuration Sections</h1>
20 <div class="toplang">
21 <p><span>Available Languages: </span><a href="./en/sections.html" title="English">&nbsp;en&nbsp;</a> |
22 <a href="./fr/sections.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a> |
23 <a href="./ja/sections.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
24 <a href="./ko/sections.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a> |
25 <a href="./tr/sections.html" hreflang="tr" rel="alternate" title="Türkçe">&nbsp;tr&nbsp;</a></p>
26 </div>
27  <p>Directives in the <a href="configuring.html">configuration files</a> may apply to the
28 entire server, or they may be restricted to apply only to particular
29 directories, files, hosts, or URLs.  This document describes how to
30 use configuration section containers or <code>.htaccess</code> files
31 to change the scope of other configuration directives.</p>
32 </div>
33 <div id="quickview"><ul id="toc"><li><img alt="" src="./images/down.gif" /> <a href="#types">Types of Configuration Section Containers</a></li>
34 <li><img alt="" src="./images/down.gif" /> <a href="#file-and-web">Filesystem and Webspace</a></li>
35 <li><img alt="" src="./images/down.gif" /> <a href="#virtualhost">Virtual Hosts</a></li>
36 <li><img alt="" src="./images/down.gif" /> <a href="#proxy">Proxy</a></li>
37 <li><img alt="" src="./images/down.gif" /> <a href="#whatwhere">What Directives are Allowed?</a></li>
38 <li><img alt="" src="./images/down.gif" /> <a href="#mergin">How the sections are merged</a></li>
39 </ul></div>
40 <div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
41 <div class="section">
42 <h2><a name="types" id="types">Types of Configuration Section Containers</a></h2>
43
44 <table class="related"><tr><th>Related Modules</th><th>Related Directives</th></tr><tr><td><ul><li><code class="module"><a href="./mod/core.html">core</a></code></li><li><code class="module"><a href="./mod/mod_version.html">mod_version</a></code></li><li><code class="module"><a href="./mod/mod_proxy.html">mod_proxy</a></code></li></ul></td><td><ul><li><code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code></li><li><code class="directive"><a href="./mod/core.html#directorymatch">&lt;DirectoryMatch&gt;</a></code></li><li><code class="directive"><a href="./mod/core.html#files">&lt;Files&gt;</a></code></li><li><code class="directive"><a href="./mod/core.html#filesmatch">&lt;FilesMatch&gt;</a></code></li><li><code class="directive"><a href="./mod/core.html#if">&lt;If&gt;</a></code></li><li><code class="directive"><a href="./mod/core.html#ifdefine">&lt;IfDefine&gt;</a></code></li><li><code class="directive"><a href="./mod/core.html#ifmodule">&lt;IfModule&gt;</a></code></li><li><code class="directive"><a href="./mod/mod_version.html#ifversion">&lt;IfVersion&gt;</a></code></li><li><code class="directive"><a href="./mod/core.html#location">&lt;Location&gt;</a></code></li><li><code class="directive"><a href="./mod/core.html#locationmatch">&lt;LocationMatch&gt;</a></code></li><li><code class="directive"><a href="./mod/mod_proxy.html#proxy">&lt;Proxy&gt;</a></code></li><li><code class="directive"><a href="./mod/mod_proxy.html#proxymatch">&lt;ProxyMatch&gt;</a></code></li><li><code class="directive"><a href="./mod/core.html#virtualhost">&lt;VirtualHost&gt;</a></code></li></ul></td></tr></table>
45
46 <p>There are two basic types of containers.  Most containers are
47 evaluated for each request.  The enclosed directives are applied only
48 for those requests that match the containers.  The <code class="directive"><a href="./mod/core.html#ifdefine">&lt;IfDefine&gt;</a></code>, <code class="directive"><a href="./mod/core.html#ifmodule">&lt;IfModule&gt;</a></code>, and
49 <code class="directive"><a href="./mod/mod_version.html#ifversion">&lt;IfVersion&gt;</a></code>
50 containers, on the other hand, are evaluated only at server startup
51 and restart.  If their conditions are true at startup, then the
52 enclosed directives will apply to all requests.  If the conditions are
53 not true, the enclosed directives will be ignored.</p>
54
55 <p>The <code class="directive"><a href="./mod/core.html#ifdefine">&lt;IfDefine&gt;</a></code> directive
56 encloses directives that will only be applied if an appropriate
57 parameter is defined on the <code class="program"><a href="./programs/httpd.html">httpd</a></code> command line.  For example,
58 with the following configuration, all requests will be redirected
59 to another site only if the server is started using
60 <code>httpd -DClosedForNow</code>:</p>
61
62 <div class="example"><p><code>
63 &lt;IfDefine ClosedForNow&gt;<br />
64 Redirect / http://otherserver.example.com/<br />
65 &lt;/IfDefine&gt;
66 </code></p></div>
67
68 <p>The <code class="directive"><a href="./mod/core.html#ifmodule">&lt;IfModule&gt;</a></code>
69 directive is very similar, except it encloses directives that will
70 only be applied if a particular module is available in the server.
71 The module must either be statically compiled in the server, or it
72 must be dynamically compiled and its <code class="directive"><a href="./mod/mod_so.html#loadmodule">LoadModule</a></code> line must be earlier in the
73 configuration file.  This directive should only be used if you need
74 your configuration file to work whether or not certain modules are
75 installed.  It should not be used to enclose directives that you want
76 to work all the time, because it can suppress useful error messages
77 about missing modules.</p>
78
79 <p>In the following example, the <code class="directive"><a href="./mod/mod_mime_magic.html#mimemagicfiles">MimeMagicFiles</a></code> directive will be
80 applied only if <code class="module"><a href="./mod/mod_mime_magic.html">mod_mime_magic</a></code> is available.</p>
81
82 <div class="example"><p><code>
83 &lt;IfModule mod_mime_magic.c&gt;<br />
84 MimeMagicFile conf/magic<br />
85 &lt;/IfModule&gt;
86 </code></p></div>
87
88 <p>The <code class="directive"><a href="./mod/mod_version.html#ifversion">&lt;IfVersion&gt;</a></code>
89 directive is very similar to <code class="directive"><a href="./mod/core.html#ifdefine">&lt;IfDefine&gt;</a></code> and <code class="directive"><a href="./mod/core.html#ifmodule">&lt;IfModule&gt;</a></code>, except it encloses directives that will
90 only be applied if a particular version of the server is executing.  This
91 module is designed for the use in test suites and large networks which have to
92 deal with different httpd versions and different configurations.</p>
93
94 <div class="example"><p><code>
95   &lt;IfVersion &gt;= 2.1&gt;<br />
96   <span class="indent">
97     # this happens only in versions greater or<br />
98     # equal 2.1.0.<br />
99   </span>
100   &lt;/IfVersion&gt;
101 </code></p></div>
102
103 <p><code class="directive"><a href="./mod/core.html#ifdefine">&lt;IfDefine&gt;</a></code>,
104 <code class="directive"><a href="./mod/core.html#ifmodule">&lt;IfModule&gt;</a></code>, and the
105 <code class="directive"><a href="./mod/mod_version.html#ifversion">&lt;IfVersion&gt;</a></code>
106 can apply negative conditions by preceding their test with "!".
107 Also, these sections can be nested to achieve more complex
108 restrictions.</p>
109 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
110 <div class="section">
111 <h2><a name="file-and-web" id="file-and-web">Filesystem and Webspace</a></h2>
112
113 <p>The most commonly used configuration section containers are the
114 ones that change the configuration of particular places in the
115 filesystem or webspace.  First, it is important to understand the
116 difference between the two.  The filesystem is the view of your disks
117 as seen by your operating system.  For example, in a default install,
118 Apache resides at <code>/usr/local/apache2</code> in the Unix
119 filesystem or <code>"c:/Program Files/Apache Group/Apache2"</code> in
120 the Windows filesystem.  (Note that forward slashes should always be
121 used as the path separator in Apache, even for Windows.)  In contrast,
122 the webspace is the view of your site as delivered by the web server
123 and seen by the client.  So the path <code>/dir/</code> in the
124 webspace corresponds to the path
125 <code>/usr/local/apache2/htdocs/dir/</code> in the filesystem of a
126 default Apache install on Unix.  The webspace need not map directly to
127 the filesystem, since webpages may be generated dynamically
128 from databases or other locations.</p>
129
130 <h3><a name="filesystem" id="filesystem">Filesystem Containers</a></h3>
131
132 <p>The <code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code>
133 and <code class="directive"><a href="./mod/core.html#files">&lt;Files&gt;</a></code>
134 directives, along with their <a class="glossarylink" href="./glossary.html#regex" title="see glossary">regex</a>
135 counterparts, apply directives to
136 parts of the filesystem.  Directives enclosed in a <code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code> section apply to
137 the named filesystem directory and all subdirectories of that
138 directory.  The same effect can be obtained using <a href="howto/htaccess.html">.htaccess files</a>.  For example, in the
139 following configuration, directory indexes will be enabled for the
140 <code>/var/web/dir1</code> directory and all subdirectories.</p>
141
142 <div class="example"><p><code>
143 &lt;Directory /var/web/dir1&gt;<br />
144 Options +Indexes<br />
145 &lt;/Directory&gt;
146 </code></p></div>
147
148 <p>Directives enclosed in a <code class="directive"><a href="./mod/core.html#files">&lt;Files&gt;</a></code> section apply to any file with
149 the specified name, regardless of what directory it lies in.
150 So for example, the following configuration directives will,
151 when placed in the main section of the configuration file,
152 deny access to any file named <code>private.html</code> regardless
153 of where it is found.</p>
154
155 <div class="example"><p><code>
156 &lt;Files private.html&gt;<br />
157 Order allow,deny<br />
158 Deny from all<br />
159 &lt;/Files&gt;
160 </code></p></div>
161
162 <p>To address files found in a particular part of the filesystem, the
163 <code class="directive"><a href="./mod/core.html#files">&lt;Files&gt;</a></code> and
164 <code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code> sections
165 can be combined.  For example, the following configuration will deny
166 access to <code>/var/web/dir1/private.html</code>,
167 <code>/var/web/dir1/subdir2/private.html</code>,
168 <code>/var/web/dir1/subdir3/private.html</code>, and any other instance
169 of <code>private.html</code> found under the <code>/var/web/dir1/</code>
170 directory.</p>
171
172 <div class="example"><p><code>
173 &lt;Directory /var/web/dir1&gt;<br />
174 &lt;Files private.html&gt;<br />
175 Order allow,deny<br />
176 Deny from all<br />
177 &lt;/Files&gt;<br />
178 &lt;/Directory&gt;
179 </code></p></div>
180
181
182 <h3><a name="webspace" id="webspace">Webspace Containers</a></h3>
183
184 <p>The <code class="directive"><a href="./mod/core.html#location">&lt;Location&gt;</a></code>
185 directive and its <a class="glossarylink" href="./glossary.html#regex" title="see glossary">regex</a> counterpart, on
186 the other hand, change the
187 configuration for content in the webspace.  For example, the following
188 configuration prevents access to any URL-path that begins in /private.
189 In particular, it will apply to requests for
190 <code>http://yoursite.example.com/private</code>,
191 <code>http://yoursite.example.com/private123</code>, and
192 <code>http://yoursite.example.com/private/dir/file.html</code> as well
193 as any other requests starting with the <code>/private</code> string.</p>
194
195 <div class="example"><p><code>
196 &lt;Location /private&gt;<br />
197 Order Allow,Deny<br />
198 Deny from all<br />
199 &lt;/Location&gt;
200 </code></p></div>
201
202 <p>The <code class="directive"><a href="./mod/core.html#location">&lt;Location&gt;</a></code>
203 directive need not have anything to do with the filesystem.
204 For example, the following example shows how to map a particular
205 URL to an internal Apache handler provided by <code class="module"><a href="./mod/mod_status.html">mod_status</a></code>.
206 No file called <code>server-status</code> needs to exist in the
207 filesystem.</p>
208
209 <div class="example"><p><code>
210 &lt;Location /server-status&gt;<br />
211 SetHandler server-status<br />
212 &lt;/Location&gt;
213 </code></p></div>
214
215
216 <h3><a name="wildcards" id="wildcards">Wildcards and Regular Expressions</a></h3>
217
218 <p>The <code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code>,
219 <code class="directive"><a href="./mod/core.html#files">&lt;Files&gt;</a></code>, and
220 <code class="directive"><a href="./mod/core.html#location">&lt;Location&gt;</a></code>
221 directives can each use shell-style wildcard characters as in
222 <code>fnmatch</code> from the C standard library.  The character "*"
223 matches any sequence of characters, "?" matches any single character,
224 and "[<em>seq</em>]" matches any character in <em>seq</em>.  The "/"
225 character will not be matched by any wildcard; it must be specified
226 explicitly.</p>
227
228 <p>If even more flexible matching is required, each
229 container has a regular expression (regex) counterpart <code class="directive"><a href="./mod/core.html#directorymatch">&lt;DirectoryMatch&gt;</a></code>, <code class="directive"><a href="./mod/core.html#filesmatch">&lt;FilesMatch&gt;</a></code>, and <code class="directive"><a href="./mod/core.html#locationmatch">&lt;LocationMatch&gt;</a></code> that allow
230 perl-compatible
231 <a class="glossarylink" href="./glossary.html#regex" title="see glossary">regular expressions</a>
232 to be used in choosing the matches.  But see the section below on
233 configuration merging to find out how using regex sections will change
234 how directives are applied.</p>
235
236 <p>A non-regex wildcard section that changes the configuration of
237 all user directories could look as follows:</p>
238
239 <div class="example"><p><code>
240 &lt;Directory /home/*/public_html&gt;<br />
241 Options Indexes<br />
242 &lt;/Directory&gt;
243 </code></p></div>
244
245 <p>Using regex sections, we can deny access to many types of image files
246 at once:</p>
247 <div class="example"><p><code>
248 &lt;FilesMatch \.(?i:gif|jpe?g|png)$&gt;<br />
249 Order allow,deny<br />
250 Deny from all<br />
251 &lt;/FilesMatch&gt;
252 </code></p></div>
253
254
255
256 <h3><a name="whichwhen" id="whichwhen">What to use When</a></h3>
257
258 <p>Choosing between filesystem containers and webspace containers is
259 actually quite easy.  When applying directives to objects that reside
260 in the filesystem always use <code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code> or <code class="directive"><a href="./mod/core.html#files">&lt;Files&gt;</a></code>.  When applying directives to objects
261 that do not reside in the filesystem (such as a webpage generated from
262 a database), use <code class="directive"><a href="./mod/core.html#location">&lt;Location&gt;</a></code>.</p>
263
264 <p>It is important to never use <code class="directive"><a href="./mod/core.html#location">&lt;Location&gt;</a></code> when trying to restrict
265 access to objects in the filesystem.  This is because many
266 different webspace locations (URLs) could map to the same filesystem
267 location, allowing your restrictions to be circumvented.
268 For example, consider the following configuration:</p>
269
270 <div class="example"><p><code>
271 &lt;Location /dir/&gt;<br />
272 Order allow,deny<br />
273 Deny from all<br />
274 &lt;/Location&gt;
275 </code></p></div>
276
277 <p>This works fine if the request is for
278 <code>http://yoursite.example.com/dir/</code>.  But what if you are on
279 a case-insensitive filesystem?  Then your restriction could be easily
280 circumvented by requesting
281 <code>http://yoursite.example.com/DIR/</code>.  The <code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code> directive, in
282 contrast, will apply to any content served from that location,
283 regardless of how it is called.  (An exception is filesystem links.
284 The same directory can be placed in more than one part of the
285 filesystem using symbolic links.  The <code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code> directive will follow the symbolic
286 link without resetting the pathname.  Therefore, for the highest level
287 of security, symbolic links should be disabled with the appropriate
288 <code class="directive"><a href="./mod/core.html#options">Options</a></code> directive.)</p>
289
290 <p>If you are, perhaps, thinking that none of this applies to you
291 because you use a case-sensitive filesystem, remember that there are
292 many other ways to map multiple webspace locations to the same
293 filesystem location.  Therefore you should always use the filesystem
294 containers when you can.  There is, however, one exception to this
295 rule.  Putting configuration restrictions in a <code>&lt;Location
296 /&gt;</code> section is perfectly safe because this section will apply
297 to all requests regardless of the specific URL.</p>
298
299
300 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
301 <div class="section">
302 <h2><a name="virtualhost" id="virtualhost">Virtual Hosts</a></h2>
303
304 <p>The <code class="directive"><a href="./mod/core.html#virtualhost">&lt;VirtualHost&gt;</a></code>
305 container encloses directives that apply to specific hosts.
306 This is useful when serving multiple hosts from the same machine
307 with a different configuration for each.  For more information,
308 see the <a href="vhosts/">Virtual Host Documentation</a>.</p>
309 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
310 <div class="section">
311 <h2><a name="proxy" id="proxy">Proxy</a></h2>
312
313 <p>The <code class="directive"><a href="./mod/mod_proxy.html#proxy">&lt;Proxy&gt;</a></code>
314 and <code class="directive"><a href="./mod/mod_proxy.html#proxymatch">&lt;ProxyMatch&gt;</a></code>
315 containers apply enclosed configuration directives only
316 to sites accessed through <code class="module"><a href="./mod/mod_proxy.html">mod_proxy</a></code>'s proxy server
317 that match the specified URL.  For example, the following configuration
318 will prevent the proxy server from being used to access the
319 <code>cnn.com</code> website.</p>
320
321 <div class="example"><p><code>
322 &lt;Proxy http://cnn.com/*&gt;<br />
323 Order allow,deny<br />
324 Deny from all<br />
325 &lt;/Proxy&gt;
326 </code></p></div>
327 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
328 <div class="section">
329 <h2><a name="whatwhere" id="whatwhere">What Directives are Allowed?</a></h2>
330
331 <p>To find out what directives are allowed in what types of
332 configuration sections, check the <a href="mod/directive-dict.html#Context">Context</a> of the directive.
333 Everything that is allowed in 
334 <code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code>
335 sections is also syntactically allowed in
336 <code class="directive"><a href="./mod/core.html#directorymatch">&lt;DirectoryMatch&gt;</a></code>,
337 <code class="directive"><a href="./mod/core.html#files">&lt;Files&gt;</a></code>,
338 <code class="directive"><a href="./mod/core.html#filesmatch">&lt;FilesMatch&gt;</a></code>,
339 <code class="directive"><a href="./mod/core.html#location">&lt;Location&gt;</a></code>,
340 <code class="directive"><a href="./mod/core.html#locationmatch">&lt;LocationMatch&gt;</a></code>,
341 <code class="directive"><a href="./mod/mod_proxy.html#proxy">&lt;Proxy&gt;</a></code>,
342 and <code class="directive"><a href="./mod/mod_proxy.html#proxymatch">&lt;ProxyMatch&gt;</a></code>
343 sections.  There are some exceptions, however:</p>
344
345 <ul>
346 <li>The <code class="directive"><a href="./mod/core.html#allowoverride">AllowOverride</a></code> directive
347 works only in <code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code>
348 sections.</li>
349
350 <li>The <code>FollowSymLinks</code> and
351 <code>SymLinksIfOwnerMatch</code> <code class="directive"><a href="./mod/core.html#options">Options</a></code> work only in <code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code> sections or
352 <code>.htaccess</code> files.</li>
353
354 <li>The <code class="directive"><a href="./mod/core.html#options">Options</a></code> directive cannot
355 be used in <code class="directive"><a href="./mod/core.html#files">&lt;Files&gt;</a></code>
356 and <code class="directive"><a href="./mod/core.html#filesmatch">&lt;FilesMatch&gt;</a></code>
357 sections.</li>
358 </ul>
359 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
360 <div class="section">
361 <h2><a name="mergin" id="mergin">How the sections are merged</a></h2>
362
363 <p>The configuration sections are applied in a very particular order.
364 Since this can have important effects on how configuration directives
365 are interpreted, it is important to understand how this works.</p>
366
367     <p>The order of merging is:</p>
368
369     <ol>
370       <li> <code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code> (except regular expressions)
371       and <code>.htaccess</code> done simultaneously (with
372       <code>.htaccess</code>, if allowed, overriding
373       <code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code>)</li>
374
375       <li><code class="directive"><a href="./mod/core.html#directorymatch">&lt;DirectoryMatch&gt;</a></code>
376       (and <code>&lt;Directory ~&gt;</code>)</li>
377
378       <li><code class="directive"><a href="./mod/core.html#files">&lt;Files&gt;</a></code> and <code class="directive"><a href="./mod/core.html#filesmatch">&lt;FilesMatch&gt;</a></code> done
379       simultaneously</li>
380
381       <li><code class="directive"><a href="./mod/core.html#location">&lt;Location&gt;</a></code>
382       and <code class="directive"><a href="./mod/core.html#locationmatch">&lt;LocationMatch&gt;</a></code> done simultaneously</li>
383     </ol>
384
385     <p>Apart from <code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code>, each group is processed in
386     the order that they appear in the configuration files.  <code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code> (group 1 above)
387     is processed in the order shortest directory component to longest.
388     So for example, <code>&lt;Directory /var/web/dir&gt;</code> will
389     be processed before <code>&lt;Directory
390     /var/web/dir/subdir&gt;</code>.  If multiple <code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code> sections apply
391     to the same directory they are processed in the configuration file
392     order. Configurations included via the <code class="directive"><a href="./mod/core.html#include">Include</a></code> directive will be treated as if
393     they were inside the including file at the location of the
394     <code class="directive"><a href="./mod/core.html#include">Include</a></code> directive.</p>
395
396     <p>Sections inside <code class="directive"><a href="./mod/core.html#virtualhost">&lt;VirtualHost&gt;</a></code> sections
397     are applied <em>after</em> the corresponding sections outside
398     the virtual host definition. This allows virtual hosts to
399     override the main server configuration.</p>
400
401     <p>When the request is served by <code class="module"><a href="./mod/mod_proxy.html">mod_proxy</a></code>, the
402     <code class="directive"><a href="./mod/mod_proxy.html#proxy">&lt;Proxy&gt;</a></code>
403     container takes the place of the <code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code> container in the processing
404     order.</p>
405
406     <p>Later sections override earlier ones.</p>
407
408 <div class="note"><h3>Technical Note</h3>
409       There is actually a
410       <code>&lt;Location&gt;</code>/<code>&lt;LocationMatch&gt;</code>
411       sequence performed just before the name translation phase
412       (where <code>Aliases</code> and <code>DocumentRoots</code>
413       are used to map URLs to filenames). The results of this
414       sequence are completely thrown away after the translation has
415       completed.
416 </div>
417
418 <h3><a name="merge-examples" id="merge-examples">Some Examples</a></h3>
419
420 <p>Below is an artificial example to show the order of
421 merging. Assuming they all apply to the request, the directives in
422 this example will be applied in the order A &gt; B &gt; C &gt; D &gt;
423 E.</p>
424
425 <div class="example"><p><code>
426 &lt;Location /&gt;<br />
427 E<br />
428 &lt;/Location&gt;<br />
429 <br />
430 &lt;Files f.html&gt;<br />
431 D<br />
432 &lt;/Files&gt;<br />
433 <br />
434 &lt;VirtualHost *&gt;<br />
435 &lt;Directory /a/b&gt;<br />
436 B<br />
437 &lt;/Directory&gt;<br />
438 &lt;/VirtualHost&gt;<br />
439 <br />
440 &lt;DirectoryMatch "^.*b$"&gt;<br />
441 C<br />
442 &lt;/DirectoryMatch&gt;<br />
443 <br />
444 &lt;Directory /a/b&gt;<br />
445 A<br />
446 &lt;/Directory&gt;<br />
447 <br />
448 </code></p></div>
449
450 <p>For a more concrete example, consider the following.  Regardless of
451 any access restrictions placed in <code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code> sections, the <code class="directive"><a href="./mod/core.html#location">&lt;Location&gt;</a></code> section will be
452 evaluated last and will allow unrestricted access to the server.  In
453 other words, order of merging is important, so be careful!</p>
454
455 <div class="example"><p><code>
456 &lt;Location /&gt;<br />
457 Order deny,allow<br />
458 Allow from all<br />
459 &lt;/Location&gt;<br />
460 <br />
461 # Woops!  This &lt;Directory&gt; section will have no effect<br />
462 &lt;Directory /&gt;<br />
463 Order allow,deny<br />
464 Allow from all<br />
465 Deny from badguy.example.com<br />
466 &lt;/Directory&gt;
467 </code></p></div>
468
469
470
471 </div></div>
472 <div class="bottomlang">
473 <p><span>Available Languages: </span><a href="./en/sections.html" title="English">&nbsp;en&nbsp;</a> |
474 <a href="./fr/sections.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a> |
475 <a href="./ja/sections.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
476 <a href="./ko/sections.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a> |
477 <a href="./tr/sections.html" hreflang="tr" rel="alternate" title="Türkçe">&nbsp;tr&nbsp;</a></p>
478 </div><div id="footer">
479 <p class="apache">Copyright 2010 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
480 <p class="menu"><a href="./mod/">Modules</a> | <a href="./mod/directives.html">Directives</a> | <a href="./faq/">FAQ</a> | <a href="./glossary.html">Glossary</a> | <a href="./sitemap.html">Sitemap</a></p></div>
481 </body></html>