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