2 <!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
3 <?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
4 <!-- $LastChangedRevision$ -->
7 Licensed to the Apache Software Foundation (ASF) under one or more
8 contributor license agreements. See the NOTICE file distributed with
9 this work for additional information regarding copyright ownership.
10 The ASF licenses this file to You under the Apache License, Version 2.0
11 (the "License"); you may not use this file except in compliance with
12 the License. You may obtain a copy of the License at
14 http://www.apache.org/licenses/LICENSE-2.0
16 Unless required by applicable law or agreed to in writing, software
17 distributed under the License is distributed on an "AS IS" BASIS,
18 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 See the License for the specific language governing permissions and
20 limitations under the License.
23 <modulesynopsis metafile="core.xml.meta">
26 <description>Core Apache HTTP Server features that are always
27 available</description>
31 <name>AcceptFilter</name>
32 <description>Configures optimizations for a Protocol's Listener Sockets</description>
33 <syntax>AcceptFilter <var>protocol</var> <var>accept_filter</var></syntax>
34 <contextlist><context>server config</context></contextlist>
35 <compatibility>Available in Apache httpd 2.1.5 and later.
36 On Windows from Apache httpd 2.3.3 and later.</compatibility>
39 <p>This directive enables operating system specific optimizations for a
40 listening socket by the Protocol type. The basic premise is for the
41 kernel to not send a socket to the server process until either data
42 is received or an entire HTTP Request is buffered. Only
43 <a href="http://www.freebsd.org/cgi/man.cgi?query=accept_filter&sektion=9">
44 FreeBSD's Accept Filters</a>, Linux's more primitive
45 <code>TCP_DEFER_ACCEPT</code>, and Windows' optimized AcceptEx()
46 are currently supported.</p>
48 <p>Using <code>none</code> for an argument will disable any accept filters
49 for that protocol. This is useful for protocols that require a server
50 send data first, such as <code>ftp:</code> or <code>nntp</code>:</p>
51 <example>AcceptFilter nntp none</example>
53 <p>The default values on FreeBSD are:</p>
55 AcceptFilter http httpready <br/>
56 AcceptFilter https dataready
59 <p>The <code>httpready</code> accept filter buffers entire HTTP requests at
60 the kernel level. Once an entire request is received, the kernel then
61 sends it to the server. See the
62 <a href="http://www.freebsd.org/cgi/man.cgi?query=accf_http&sektion=9">
63 accf_http(9)</a> man page for more details. Since HTTPS requests are
64 encrypted only the <a href="http://www.freebsd.org/cgi/man.cgi?query=accf_data&sektion=9">
65 accf_data(9)</a> filter is used.</p>
67 <p>The default values on Linux are:</p>
69 AcceptFilter http data <br/>
70 AcceptFilter https data
73 <p>Linux's <code>TCP_DEFER_ACCEPT</code> does not support buffering http
74 requests. Any value besides <code>none</code> will enable
75 <code>TCP_DEFER_ACCEPT</code> on that listener. For more details
77 <a href="http://homepages.cwi.nl/~aeb/linux/man2html/man7/tcp.7.html">
78 tcp(7)</a> man page.</p>
80 <p>The default values on Windows are:</p>
82 AcceptFilter http data <br/>
83 AcceptFilter https data
86 <p>Window's mpm_winnt interprets the AcceptFilter to toggle the AcceptEx()
87 API, and does not support http protocol buffering. There are two values
88 which utilize the Windows AcceptEx() API and will recycle network
89 sockets between connections. <code>data</code> waits until data has
90 been transmitted as documented above, and the initial data buffer and
91 network endpoint addresses are all retrieved from the single AcceptEx()
92 invocation. <code>connect</code> will use the AcceptEx() API, also
93 retrieve the network endpoint addresses, but like <code>none</code>
94 the <code>connect</code> option does not wait for the initial data
97 <p>On Windows, <code>none</code> uses accept() rather than than AcceptEx()
98 and will not recycle sockets between connections. This is useful for
99 network adapters with broken driver support, as well as some virtual
100 network providers such as vpn drivers, or spam, virus or spyware
107 <name>AcceptPathInfo</name>
108 <description>Resources accept trailing pathname information</description>
109 <syntax>AcceptPathInfo On|Off|Default</syntax>
110 <default>AcceptPathInfo Default</default>
111 <contextlist><context>server config</context>
112 <context>virtual host</context><context>directory</context>
113 <context>.htaccess</context></contextlist>
114 <override>FileInfo</override>
115 <compatibility>Available in Apache httpd 2.0.30 and later</compatibility>
119 <p>This directive controls whether requests that contain trailing
120 pathname information that follows an actual filename (or
121 non-existent file in an existing directory) will be accepted or
122 rejected. The trailing pathname information can be made
123 available to scripts in the <code>PATH_INFO</code> environment
126 <p>For example, assume the location <code>/test/</code> points to
127 a directory that contains only the single file
128 <code>here.html</code>. Then requests for
129 <code>/test/here.html/more</code> and
130 <code>/test/nothere.html/more</code> both collect
131 <code>/more</code> as <code>PATH_INFO</code>.</p>
133 <p>The three possible arguments for the
134 <directive>AcceptPathInfo</directive> directive are:</p>
136 <dt><code>Off</code></dt><dd>A request will only be accepted if it
137 maps to a literal path that exists. Therefore a request with
138 trailing pathname information after the true filename such as
139 <code>/test/here.html/more</code> in the above example will return
140 a 404 NOT FOUND error.</dd>
142 <dt><code>On</code></dt><dd>A request will be accepted if a
143 leading path component maps to a file that exists. The above
144 example <code>/test/here.html/more</code> will be accepted if
145 <code>/test/here.html</code> maps to a valid file.</dd>
147 <dt><code>Default</code></dt><dd>The treatment of requests with
148 trailing pathname information is determined by the <a
149 href="../handler.html">handler</a> responsible for the request.
150 The core handler for normal files defaults to rejecting
151 <code>PATH_INFO</code> requests. Handlers that serve scripts, such as <a
152 href="mod_cgi.html">cgi-script</a> and <a
153 href="mod_isapi.html">isapi-handler</a>, generally accept
154 <code>PATH_INFO</code> by default.</dd>
157 <p>The primary purpose of the <code>AcceptPathInfo</code>
158 directive is to allow you to override the handler's choice of
159 accepting or rejecting <code>PATH_INFO</code>. This override is required,
160 for example, when you use a <a href="../filter.html">filter</a>, such
161 as <a href="mod_include.html">INCLUDES</a>, to generate content
162 based on <code>PATH_INFO</code>. The core handler would usually reject
163 the request, so you can use the following configuration to enable
167 <Files "mypaths.shtml"><br />
169 Options +Includes<br />
170 SetOutputFilter INCLUDES<br />
171 AcceptPathInfo On<br />
180 <name>AccessFileName</name>
181 <description>Name of the distributed configuration file</description>
182 <syntax>AccessFileName <var>filename</var> [<var>filename</var>] ...</syntax>
183 <default>AccessFileName .htaccess</default>
184 <contextlist><context>server config</context><context>virtual host</context>
188 <p>While processing a request the server looks for
189 the first existing configuration file from this list of names in
190 every directory of the path to the document, if distributed
191 configuration files are <a href="#allowoverride">enabled for that
192 directory</a>. For example:</p>
198 <p>before returning the document
199 <code>/usr/local/web/index.html</code>, the server will read
200 <code>/.acl</code>, <code>/usr/.acl</code>,
201 <code>/usr/local/.acl</code> and <code>/usr/local/web/.acl</code>
202 for directives, unless they have been disabled with</p>
205 <Directory /><br />
207 AllowOverride None<br />
212 <seealso><directive module="core">AllowOverride</directive></seealso>
213 <seealso><a href="../configuring.html">Configuration Files</a></seealso>
214 <seealso><a href="../howto/htaccess.html">.htaccess Files</a></seealso>
218 <name>AddDefaultCharset</name>
219 <description>Default charset parameter to be added when a response
220 content-type is <code>text/plain</code> or <code>text/html</code></description>
221 <syntax>AddDefaultCharset On|Off|<var>charset</var></syntax>
222 <default>AddDefaultCharset Off</default>
223 <contextlist><context>server config</context>
224 <context>virtual host</context><context>directory</context>
225 <context>.htaccess</context></contextlist>
226 <override>FileInfo</override>
229 <p>This directive specifies a default value for the media type
230 charset parameter (the name of a character encoding) to be added
231 to a response if and only if the response's content-type is either
232 <code>text/plain</code> or <code>text/html</code>. This should override
233 any charset specified in the body of the response via a <code>META</code>
234 element, though the exact behavior is often dependent on the user's client
235 configuration. A setting of <code>AddDefaultCharset Off</code>
236 disables this functionality. <code>AddDefaultCharset On</code> enables
237 a default charset of <code>iso-8859-1</code>. Any other value is assumed
238 to be the <var>charset</var> to be used, which should be one of the
239 <a href="http://www.iana.org/assignments/character-sets">IANA registered
240 charset values</a> for use in Internet media types (MIME types).
244 AddDefaultCharset utf-8
247 <p><directive>AddDefaultCharset</directive> should only be used when all
248 of the text resources to which it applies are known to be in that
249 character encoding and it is too inconvenient to label their charset
250 individually. One such example is to add the charset parameter
251 to resources containing generated content, such as legacy CGI
252 scripts, that might be vulnerable to cross-site scripting attacks
253 due to user-provided data being included in the output. Note, however,
254 that a better solution is to just fix (or delete) those scripts, since
255 setting a default charset does not protect users that have enabled
256 the "auto-detect character encoding" feature on their browser.</p>
258 <seealso><directive module="mod_mime">AddCharset</directive></seealso>
262 <name>AddOutputFilterByType</name>
263 <description>assigns an output filter to a particular media-type</description>
264 <syntax>AddOutputFilterByType <var>filter</var>[;<var>filter</var>...]
265 <var>media-type</var> [<var>media-type</var>] ...</syntax>
266 <contextlist><context>server config</context>
267 <context>virtual host</context><context>directory</context>
268 <context>.htaccess</context></contextlist>
269 <override>FileInfo</override>
270 <compatibility>Available in Apache httpd 2.0.33 and later; deprecated in Apache httpd 2.1 and later</compatibility>
273 <p>This directive activates a particular output <a
274 href="../filter.html">filter</a> for a request depending on the
275 response <glossary>media-type</glossary>. Because of certain
276 problems discussed below, this directive is deprecated. The same
277 functionality is available using <module>mod_filter</module>.</p>
279 <p>The following example uses the <code>DEFLATE</code> filter, which
280 is provided by <module>mod_deflate</module>. It will compress all
281 output (either static or dynamic) which is labeled as
282 <code>text/html</code> or <code>text/plain</code> before it is sent
286 AddOutputFilterByType DEFLATE text/html text/plain
289 <p>If you want the content to be processed by more than one filter, their
290 names have to be separated by semicolons. It's also possible to use one
291 <directive>AddOutputFilterByType</directive> directive for each of
294 <p>The configuration below causes all script output labeled as
295 <code>text/html</code> to be processed at first by the
296 <code>INCLUDES</code> filter and then by the <code>DEFLATE</code>
300 <Location /cgi-bin/><br />
302 Options Includes<br />
303 AddOutputFilterByType INCLUDES;DEFLATE text/html<br />
308 <note type="warning"><title>Note</title>
309 <p>Enabling filters with <directive>AddOutputFilterByType</directive>
310 may fail partially or completely in some cases. For example, no
311 filters are applied if the <glossary>media-type</glossary> could not
312 be determined. If you want to make sure that the filters will be
313 applied, assign the content type to a resource explicitly; for
314 example, with <directive module="mod_mime">AddType</directive> or
315 <directive module="core">ForceType</directive>. Setting the
316 content type within a (non-nph) CGI script is also safe.</p>
321 <seealso><directive module="mod_mime">AddOutputFilter</directive></seealso>
322 <seealso><directive module="core">SetOutputFilter</directive></seealso>
323 <seealso><a href="../filter.html">filters</a></seealso>
327 <name>AllowEncodedSlashes</name>
328 <description>Determines whether encoded path separators in URLs are allowed to
329 be passed through</description>
330 <syntax>AllowEncodedSlashes On|Off</syntax>
331 <default>AllowEncodedSlashes Off</default>
332 <contextlist><context>server config</context><context>virtual host</context>
334 <compatibility>Available in Apache httpd 2.0.46 and later</compatibility>
337 <p>The <directive>AllowEncodedSlashes</directive> directive allows URLs
338 which contain encoded path separators (<code>%2F</code> for <code>/</code>
339 and additionally <code>%5C</code> for <code>\</code> on according systems)
340 to be used. Normally such URLs are refused with a 404 (Not found) error.</p>
342 <p>Turning <directive>AllowEncodedSlashes</directive> <code>On</code> is
343 mostly useful when used in conjunction with <code>PATH_INFO</code>.</p>
345 <note><title>Note</title>
346 <p>Allowing encoded slashes does <em>not</em> imply <em>decoding</em>.
347 Occurrences of <code>%2F</code> or <code>%5C</code> (<em>only</em> on
348 according systems) will be left as such in the otherwise decoded URL
352 <seealso><directive module="core">AcceptPathInfo</directive></seealso>
356 <name>AllowOverride</name>
357 <description>Types of directives that are allowed in
358 <code>.htaccess</code> files</description>
359 <syntax>AllowOverride All|None|<var>directive-type</var>
360 [<var>directive-type</var>] ...</syntax>
361 <default>AllowOverride All</default>
362 <contextlist><context>directory</context></contextlist>
365 <p>When the server finds an <code>.htaccess</code> file (as
366 specified by <directive module="core">AccessFileName</directive>)
367 it needs to know which directives declared in that file can override
368 earlier configuration directives.</p>
370 <note><title>Only available in <Directory> sections</title>
371 <directive>AllowOverride</directive> is valid only in
372 <directive type="section" module="core">Directory</directive>
373 sections specified without regular expressions, not in <directive
374 type="section" module="core">Location</directive>, <directive
375 module="core" type="section">DirectoryMatch</directive> or
376 <directive type="section" module="core">Files</directive> sections.
379 <p>When this directive is set to <code>None</code>, then
380 <a href="#accessfilename">.htaccess</a> files are completely ignored.
381 In this case, the server will not even attempt to read
382 <code>.htaccess</code> files in the filesystem.</p>
384 <p>When this directive is set to <code>All</code>, then any
385 directive which has the .htaccess <a
386 href="directive-dict.html#Context">Context</a> is allowed in
387 <code>.htaccess</code> files.</p>
389 <p>The <var>directive-type</var> can be one of the following
390 groupings of directives.</p>
397 Allow use of the authorization directives (<directive
398 module="mod_authn_dbm">AuthDBMGroupFile</directive>,
399 <directive module="mod_authn_dbm">AuthDBMUserFile</directive>,
400 <directive module="mod_authz_groupfile">AuthGroupFile</directive>,
401 <directive module="mod_authn_core">AuthName</directive>,
402 <directive module="mod_authn_core">AuthType</directive>, <directive
403 module="mod_authn_file">AuthUserFile</directive>, <directive
404 module="mod_authz_core">Require</directive>, <em>etc.</em>).</dd>
409 Allow use of the directives controlling document types
410 (<directive module="core">ErrorDocument</directive>,
411 <directive module="core">ForceType</directive>,
412 <directive module="mod_negotiation">LanguagePriority</directive>,
413 <directive module="core">SetHandler</directive>,
414 <directive module="core">SetInputFilter</directive>,
415 <directive module="core">SetOutputFilter</directive>, and
416 <module>mod_mime</module> Add* and Remove* directives),
417 document meta data (<directive
418 module="mod_headers">Header</directive>, <directive
419 module="mod_headers">RequestHeader</directive>, <directive
420 module="mod_setenvif">SetEnvIf</directive>, <directive
421 module="mod_setenvif">SetEnvIfNoCase</directive>, <directive
422 module="mod_setenvif">BrowserMatch</directive>, <directive
423 module="mod_usertrack">CookieExpires</directive>, <directive
424 module="mod_usertrack">CookieDomain</directive>, <directive
425 module="mod_usertrack">CookieStyle</directive>, <directive
426 module="mod_usertrack">CookieTracking</directive>, <directive
427 module="mod_usertrack">CookieName</directive>),
428 <module>mod_rewrite</module> directives <directive
429 module="mod_rewrite">RewriteEngine</directive>, <directive
430 module="mod_rewrite">RewriteOptions</directive>, <directive
431 module="mod_rewrite">RewriteBase</directive>, <directive
432 module="mod_rewrite">RewriteCond</directive>, <directive
433 module="mod_rewrite">RewriteRule</directive>) and
434 <directive module="mod_actions">Action</directive> from
435 <module>mod_actions</module>.
441 Allow use of the directives controlling directory indexing
443 module="mod_autoindex">AddDescription</directive>,
444 <directive module="mod_autoindex">AddIcon</directive>, <directive
445 module="mod_autoindex">AddIconByEncoding</directive>,
446 <directive module="mod_autoindex">AddIconByType</directive>,
447 <directive module="mod_autoindex">DefaultIcon</directive>, <directive
448 module="mod_dir">DirectoryIndex</directive>, <directive
449 module="mod_autoindex">FancyIndexing</directive>, <directive
450 module="mod_autoindex">HeaderName</directive>, <directive
451 module="mod_autoindex">IndexIgnore</directive>, <directive
452 module="mod_autoindex">IndexOptions</directive>, <directive
453 module="mod_autoindex">ReadmeName</directive>,
459 Allow use of the directives controlling host access (<directive
460 module="mod_authz_host">Allow</directive>, <directive
461 module="mod_authz_host">Deny</directive> and <directive
462 module="mod_authz_host">Order</directive>).</dd>
464 <dt>Options[=<var>Option</var>,...]</dt>
467 Allow use of the directives controlling specific directory
468 features (<directive module="core">Options</directive> and
469 <directive module="mod_include">XBitHack</directive>).
470 An equal sign may be given followed by a comma (but no spaces)
471 separated lists of options that may be set using the <directive
472 module="core">Options</directive> command.</dd>
478 AllowOverride AuthConfig Indexes
481 <p>In the example above all directives that are neither in the group
482 <code>AuthConfig</code> nor <code>Indexes</code> cause an internal
485 <note><p>For security and performance reasons, do not set
486 <code>AllowOverride</code> to anything other than <code>None</code>
487 in your <code><Directory /></code> block. Instead, find (or
488 create) the <code><Directory></code> block that refers to the
489 directory where you're actually planning to place a
490 <code>.htaccess</code> file.</p>
494 <seealso><directive module="core">AccessFileName</directive></seealso>
495 <seealso><a href="../configuring.html">Configuration Files</a></seealso>
496 <seealso><a href="../howto/htaccess.html">.htaccess Files</a></seealso>
500 <name>CGIMapExtension</name>
501 <description>Technique for locating the interpreter for CGI
502 scripts</description>
503 <syntax>CGIMapExtension <var>cgi-path</var> <var>.extension</var></syntax>
504 <contextlist><context>directory</context><context>.htaccess</context>
506 <override>FileInfo</override>
507 <compatibility>NetWare only</compatibility>
510 <p>This directive is used to control how Apache httpd finds the
511 interpreter used to run CGI scripts. For example, setting
512 <code>CGIMapExtension sys:\foo.nlm .foo</code> will
513 cause all CGI script files with a <code>.foo</code> extension to
514 be passed to the FOO interpreter.</p>
519 <name>ContentDigest</name>
520 <description>Enables the generation of <code>Content-MD5</code> HTTP Response
521 headers</description>
522 <syntax>ContentDigest On|Off</syntax>
523 <default>ContentDigest Off</default>
524 <contextlist><context>server config</context><context>virtual host</context>
525 <context>directory</context><context>.htaccess</context>
527 <override>Options</override>
528 <status>Experimental</status>
531 <p>This directive enables the generation of
532 <code>Content-MD5</code> headers as defined in RFC1864
533 respectively RFC2616.</p>
535 <p>MD5 is an algorithm for computing a "message digest"
536 (sometimes called "fingerprint") of arbitrary-length data, with
537 a high degree of confidence that any alterations in the data
538 will be reflected in alterations in the message digest.</p>
540 <p>The <code>Content-MD5</code> header provides an end-to-end
541 message integrity check (MIC) of the entity-body. A proxy or
542 client may check this header for detecting accidental
543 modification of the entity-body in transit. Example header:</p>
546 Content-MD5: AuLb7Dp1rqtRtxz2m9kRpA==
549 <p>Note that this can cause performance problems on your server
550 since the message digest is computed on every request (the
551 values are not cached).</p>
553 <p><code>Content-MD5</code> is only sent for documents served
554 by the <module>core</module>, and not by any module. For example,
555 SSI documents, output from CGI scripts, and byte range responses
556 do not have this header.</p>
561 <name>DefaultType</name>
562 <description>This directive has no effect other than to emit warnings
563 if the value is not <code>none</code>. In prior versions, DefaultType
564 would specify a default media type to assign to response content for
565 which no other media type configuration could be found.
567 <syntax>DefaultType <var>media-type|none</var></syntax>
568 <default>DefaultType none</default>
569 <contextlist><context>server config</context><context>virtual host</context>
570 <context>directory</context><context>.htaccess</context>
572 <override>FileInfo</override>
573 <compatibility>The argument <code>none</code> is available in Apache httpd 2.2.7 and later. All other choices are DISABLED for 2.3.x and later.</compatibility>
576 <p>This directive has been disabled. For backwards compatibility
577 of configuration files, it may be specified with the value
578 <code>none</code>, meaning no default media type. For example:</p>
584 <p><code>DefaultType None</code> is only available in
585 httpd-2.2.7 and later.</p>
587 <p>Use the mime.types configuration file and the
588 <directive module="mod_mime">AddType</directive> to configure media
589 type assignments via file extensions, or the
590 <directive module="core">ForceType</directive> directive to configure
591 the media type for specific resources. Otherwise, the server will
592 send the response without a Content-Type header field and the
593 recipient may attempt to guess the media type.</p>
599 <description>Define the existence of a variable</description>
600 <syntax>Define <var>parameter-name</var></syntax>
601 <contextlist><context>server config</context></contextlist>
604 <p>Equivalent to passing the <code>-D</code> argument to <program
605 >httpd</program>.</p>
606 <p>This directive can be used to toggle the use of <directive module="core"
607 type="section">IfDefine</directive> sections without needing to alter
608 <code>-D</code> arguments in any startup scripts.</p>
612 <directivesynopsis type="section">
613 <name>Directory</name>
614 <description>Enclose a group of directives that apply only to the
615 named file-system directory and sub-directories</description>
616 <syntax><Directory <var>directory-path</var>>
617 ... </Directory></syntax>
618 <contextlist><context>server config</context><context>virtual host</context>
622 <p><directive type="section">Directory</directive> and
623 <code></Directory></code> are used to enclose a group of
624 directives that will apply only to the named directory and
625 sub-directories of that directory. Any directive that is allowed
626 in a directory context may be used. <var>Directory-path</var> is
627 either the full path to a directory, or a wild-card string using
628 Unix shell-style matching. In a wild-card string, <code>?</code> matches
629 any single character, and <code>*</code> matches any sequences of
630 characters. You may also use <code>[]</code> character ranges. None
631 of the wildcards match a `/' character, so <code><Directory
632 /*/public_html></code> will not match
633 <code>/home/user/public_html</code>, but <code><Directory
634 /home/*/public_html></code> will match. Example:</p>
637 <Directory /usr/local/httpd/htdocs><br />
639 Options Indexes FollowSymLinks<br />
645 <p>Be careful with the <var>directory-path</var> arguments:
646 They have to literally match the filesystem path which Apache httpd uses
647 to access the files. Directives applied to a particular
648 <code><Directory></code> will not apply to files accessed from
649 that same directory via a different path, such as via different symbolic
653 <p><glossary ref="regex">Regular
654 expressions</glossary> can also be used, with the addition of the
655 <code>~</code> character. For example:</p>
658 <Directory ~ "^/www/.*/[0-9]{3}">
661 <p>would match directories in <code>/www/</code> that consisted of
664 <p>If multiple (non-regular expression) <directive
665 type="section">Directory</directive> sections
666 match the directory (or one of its parents) containing a document,
667 then the directives are applied in the order of shortest match
668 first, interspersed with the directives from the <a
669 href="#accessfilename">.htaccess</a> files. For example,
673 <Directory /><br />
675 AllowOverride None<br />
677 </Directory><br />
679 <Directory /home/><br />
681 AllowOverride FileInfo<br />
686 <p>for access to the document <code>/home/web/dir/doc.html</code>
690 <li>Apply directive <code>AllowOverride None</code>
691 (disabling <code>.htaccess</code> files).</li>
693 <li>Apply directive <code>AllowOverride FileInfo</code> (for
694 directory <code>/home</code>).</li>
696 <li>Apply any <code>FileInfo</code> directives in
697 <code>/home/.htaccess</code>, <code>/home/web/.htaccess</code> and
698 <code>/home/web/dir/.htaccess</code> in that order.</li>
701 <p>Regular expressions are not considered until after all of the
702 normal sections have been applied. Then all of the regular
703 expressions are tested in the order they appeared in the
704 configuration file. For example, with</p>
707 <Directory ~ abc$><br />
709 # ... directives here ...<br />
714 <p>the regular expression section won't be considered until after
715 all normal <directive type="section">Directory</directive>s and
716 <code>.htaccess</code> files have been applied. Then the regular
717 expression will match on <code>/home/abc/public_html/abc</code> and
718 the corresponding <directive type="section">Directory</directive> will
721 <p><strong>Note that the default access for
722 <code><Directory /></code> is <code>Allow from All</code>.
723 This means that Apache httpd will serve any file mapped from an URL. It is
724 recommended that you change this with a block such
728 <Directory /><br />
730 Order Deny,Allow<br />
736 <p><strong>and then override this for directories you
737 <em>want</em> accessible. See the <a
738 href="../misc/security_tips.html">Security Tips</a> page for more
739 details.</strong></p>
741 <p>The directory sections occur in the <code>httpd.conf</code> file.
742 <directive type="section">Directory</directive> directives
743 cannot nest, and cannot appear in a <directive module="core"
744 type="section">Limit</directive> or <directive module="core"
745 type="section">LimitExcept</directive> section.</p>
747 <seealso><a href="../sections.html">How <Directory>,
748 <Location> and <Files> sections work</a> for an
749 explanation of how these different sections are combined when a
750 request is received</seealso>
753 <directivesynopsis type="section">
754 <name>DirectoryMatch</name>
755 <description>Enclose directives that apply to
756 file-system directories matching a regular expression and their
757 subdirectories</description>
758 <syntax><DirectoryMatch <var>regex</var>>
759 ... </DirectoryMatch></syntax>
760 <contextlist><context>server config</context><context>virtual host</context>
764 <p><directive type="section">DirectoryMatch</directive> and
765 <code></DirectoryMatch></code> are used to enclose a group
766 of directives which will apply only to the named directory and
767 sub-directories of that directory, the same as <directive
768 module="core" type="section">Directory</directive>. However, it
769 takes as an argument a <glossary ref="regex">regular
770 expression</glossary>. For example:</p>
773 <DirectoryMatch "^/www/(.+/)?[0-9]{3}">
776 <p>would match directories in <code>/www/</code> that consisted of three
779 <seealso><directive type="section" module="core">Directory</directive> for
780 a description of how regular expressions are mixed in with normal
781 <directive type="section">Directory</directive>s</seealso>
783 href="../sections.html">How <Directory>, <Location> and
784 <Files> sections work</a> for an explanation of how these different
785 sections are combined when a request is received</seealso>
789 <name>DocumentRoot</name>
790 <description>Directory that forms the main document tree visible
791 from the web</description>
792 <syntax>DocumentRoot <var>directory-path</var></syntax>
793 <default>DocumentRoot /usr/local/apache/htdocs</default>
794 <contextlist><context>server config</context><context>virtual host</context>
798 <p>This directive sets the directory from which <program>httpd</program>
799 will serve files. Unless matched by a directive like <directive
800 module="mod_alias">Alias</directive>, the server appends the
801 path from the requested URL to the document root to make the
802 path to the document. Example:</p>
805 DocumentRoot /usr/web
809 <code>http://www.my.host.com/index.html</code> refers to
810 <code>/usr/web/index.html</code>. If the <var>directory-path</var> is
811 not absolute then it is assumed to be relative to the <directive
812 module="core">ServerRoot</directive>.</p>
814 <p>The <directive>DocumentRoot</directive> should be specified without
815 a trailing slash.</p>
817 <seealso><a href="../urlmapping.html#documentroot">Mapping URLs to Filesystem
818 Locations</a></seealso>
822 <name>EnableMMAP</name>
823 <description>Use memory-mapping to read files during delivery</description>
824 <syntax>EnableMMAP On|Off</syntax>
825 <default>EnableMMAP On</default>
826 <contextlist><context>server config</context><context>virtual host</context>
827 <context>directory</context><context>.htaccess</context>
829 <override>FileInfo</override>
832 <p>This directive controls whether the <program>httpd</program> may use
833 memory-mapping if it needs to read the contents of a file during
834 delivery. By default, when the handling of a request requires
835 access to the data within a file -- for example, when delivering a
836 server-parsed file using <module>mod_include</module> -- Apache httpd
837 memory-maps the file if the OS supports it.</p>
839 <p>This memory-mapping sometimes yields a performance improvement.
840 But in some environments, it is better to disable the memory-mapping
841 to prevent operational problems:</p>
844 <li>On some multiprocessor systems, memory-mapping can reduce the
845 performance of the <program>httpd</program>.</li>
846 <li>Deleting or truncating a file while <program>httpd</program>
847 has it memory-mapped can cause <program>httpd</program> to
848 crash with a segmentation fault.
852 <p>For server configurations that are vulnerable to these problems,
853 you should disable memory-mapping of delivered files by specifying:</p>
859 <p>For NFS mounted files, this feature may be disabled explicitly for
860 the offending files by specifying:</p>
863 <Directory "/path-to-nfs-files">
873 <name>EnableSendfile</name>
874 <description>Use the kernel sendfile support to deliver files to the client</description>
875 <syntax>EnableSendfile On|Off</syntax>
876 <default>EnableSendfile On</default>
877 <contextlist><context>server config</context><context>virtual host</context>
878 <context>directory</context><context>.htaccess</context>
880 <override>FileInfo</override>
881 <compatibility>Available in version 2.0.44 and later</compatibility>
884 <p>This directive controls whether <program>httpd</program> may use the
885 sendfile support from the kernel to transmit file contents to the client.
886 By default, when the handling of a request requires no access
887 to the data within a file -- for example, when delivering a
888 static file -- Apache httpd uses sendfile to deliver the file contents
889 without ever reading the file if the OS supports it.</p>
891 <p>This sendfile mechanism avoids separate read and send operations,
892 and buffer allocations. But on some platforms or within some
893 filesystems, it is better to disable this feature to avoid
894 operational problems:</p>
897 <li>Some platforms may have broken sendfile support that the build
898 system did not detect, especially if the binaries were built on
899 another box and moved to such a machine with broken sendfile
901 <li>On Linux the use of sendfile triggers TCP-checksum
902 offloading bugs on certain networking cards when using IPv6.</li>
903 <li>On Linux on Itanium, sendfile may be unable to handle files
904 over 2GB in size.</li>
905 <li>With a network-mounted <directive
906 module="core">DocumentRoot</directive> (e.g., NFS or SMB),
907 the kernel may be unable to serve the network file through
911 <p>For server configurations that are vulnerable to these problems,
912 you should disable this feature by specifying:</p>
918 <p>For NFS or SMB mounted files, this feature may be disabled explicitly
919 for the offending files by specifying:</p>
922 <Directory "/path-to-nfs-files">
928 <p>Please note that the per-directory and .htaccess configuration
929 of <directive>EnableSendfile</directive> is not supported by
930 <module>mod_disk_cache</module>.
931 Only global definition of <directive>EnableSendfile</directive>
932 is taken into account by the module.
938 <name>ErrorDocument</name>
939 <description>What the server will return to the client
940 in case of an error</description>
941 <syntax>ErrorDocument <var>error-code</var> <var>document</var></syntax>
942 <contextlist><context>server config</context><context>virtual host</context>
943 <context>directory</context><context>.htaccess</context>
945 <override>FileInfo</override>
946 <compatibility>Quoting syntax for text messages is different in Apache HTTP Server
950 <p>In the event of a problem or error, Apache httpd can be configured
951 to do one of four things,</p>
954 <li>output a simple hardcoded error message</li>
956 <li>output a customized message</li>
958 <li>redirect to a local <var>URL-path</var> to handle the
961 <li>redirect to an external <var>URL</var> to handle the
965 <p>The first option is the default, while options 2-4 are
966 configured using the <directive>ErrorDocument</directive>
967 directive, which is followed by the HTTP response code and a URL
968 or a message. Apache httpd will sometimes offer additional information
969 regarding the problem/error.</p>
971 <p>URLs can begin with a slash (/) for local web-paths (relative
972 to the <directive module="core">DocumentRoot</directive>), or be a
973 full URL which the client can resolve. Alternatively, a message
974 can be provided to be displayed by the browser. Examples:</p>
977 ErrorDocument 500 http://foo.example.com/cgi-bin/tester<br />
978 ErrorDocument 404 /cgi-bin/bad_urls.pl<br />
979 ErrorDocument 401 /subscription_info.html<br />
980 ErrorDocument 403 "Sorry can't allow you access today"
983 <p>Additionally, the special value <code>default</code> can be used
984 to specify Apache httpd's simple hardcoded message. While not required
985 under normal circumstances, <code>default</code> will restore
986 Apache httpd's simple hardcoded message for configurations that would
987 otherwise inherit an existing <directive>ErrorDocument</directive>.</p>
990 ErrorDocument 404 /cgi-bin/bad_urls.pl<br /><br />
991 <Directory /web/docs><br />
993 ErrorDocument 404 default<br />
998 <p>Note that when you specify an <directive>ErrorDocument</directive>
999 that points to a remote URL (ie. anything with a method such as
1000 <code>http</code> in front of it), Apache HTTP Server will send a redirect to the
1001 client to tell it where to find the document, even if the
1002 document ends up being on the same server. This has several
1003 implications, the most important being that the client will not
1004 receive the original error status code, but instead will
1005 receive a redirect status code. This in turn can confuse web
1006 robots and other clients which try to determine if a URL is
1007 valid using the status code. In addition, if you use a remote
1008 URL in an <code>ErrorDocument 401</code>, the client will not
1009 know to prompt the user for a password since it will not
1010 receive the 401 status code. Therefore, <strong>if you use an
1011 <code>ErrorDocument 401</code> directive then it must refer to a local
1012 document.</strong></p>
1014 <p>Microsoft Internet Explorer (MSIE) will by default ignore
1015 server-generated error messages when they are "too small" and substitute
1016 its own "friendly" error messages. The size threshold varies depending on
1017 the type of error, but in general, if you make your error document
1018 greater than 512 bytes, then MSIE will show the server-generated
1019 error rather than masking it. More information is available in
1020 Microsoft Knowledge Base article <a
1021 href="http://support.microsoft.com/default.aspx?scid=kb;en-us;Q294807"
1024 <p>Although most error messages can be overriden, there are certain
1025 circumstances where the internal messages are used regardless of the
1026 setting of <directive module="core">ErrorDocument</directive>. In
1027 particular, if a malformed request is detected, normal request processing
1028 will be immediately halted and the internal error message returned.
1029 This is necessary to guard against security problems caused by
1032 <p>If you are using mod_proxy, you may wish to enable
1033 <directive module="mod_proxy">ProxyErrorOverride</directive> so that you can provide
1034 custom error messages on behalf of your Origin servers. If you don't enable ProxyErrorOverride,
1035 Apache httpd will not generate custom error documents for proxied content.</p>
1038 <seealso><a href="../custom-error.html">documentation of
1039 customizable responses</a></seealso>
1040 </directivesynopsis>
1043 <name>ErrorLog</name>
1044 <description>Location where the server will log errors</description>
1045 <syntax> ErrorLog <var>file-path</var>|syslog[:<var>facility</var>]</syntax>
1046 <default>ErrorLog logs/error_log (Unix) ErrorLog logs/error.log (Windows and OS/2)</default>
1047 <contextlist><context>server config</context><context>virtual host</context>
1051 <p>The <directive>ErrorLog</directive> directive sets the name of
1052 the file to which the server will log any errors it encounters. If
1053 the <var>file-path</var> is not absolute then it is assumed to be
1054 relative to the <directive module="core">ServerRoot</directive>.</p>
1056 <example><title>Example</title>
1057 ErrorLog /var/log/httpd/error_log
1060 <p>If the <var>file-path</var>
1061 begins with a pipe (|) then it is assumed to be a command to spawn
1062 to handle the error log.</p>
1064 <example><title>Example</title>
1065 ErrorLog "|/usr/local/bin/httpd_errors"
1068 <p>Using <code>syslog</code> instead of a filename enables logging
1069 via syslogd(8) if the system supports it. The default is to use
1070 syslog facility <code>local7</code>, but you can override this by
1071 using the <code>syslog:<var>facility</var></code> syntax where
1072 <var>facility</var> can be one of the names usually documented in
1075 <example><title>Example</title>
1076 ErrorLog syslog:user
1079 <p>SECURITY: See the <a
1080 href="../misc/security_tips.html#serverroot">security tips</a>
1081 document for details on why your security could be compromised
1082 if the directory where log files are stored is writable by
1083 anyone other than the user that starts the server.</p>
1084 <note type="warning"><title>Note</title>
1085 <p>When entering a file path on non-Unix platforms, care should be taken
1086 to make sure that only forward slashed are used even though the platform
1087 may allow the use of back slashes. In general it is a good idea to always
1088 use forward slashes throughout the configuration files.</p>
1091 <seealso><directive module="core">LogLevel</directive></seealso>
1092 <seealso><a href="../logs.html">Apache HTTP Server Log Files</a></seealso>
1093 </directivesynopsis>
1096 <name>ExtendedStatus</name>
1097 <description>Keep track of extended status information for each
1098 request</description>
1099 <syntax>ExtendedStatus On|Off</syntax>
1100 <default>ExtendedStatus Off[*]</default>
1101 <contextlist><context>server config</context></contextlist>
1104 <p>This option tracks additional data per worker about the
1105 currently executing request, and a utilization summary; you
1106 can see these variables during runtime by configuring
1107 <module>mod_status</module>. Note that other modules may
1108 rely on this scoreboard.</p>
1110 <p>This setting applies to the entire server, and cannot be
1111 enabled or disabled on a virtualhost-by-virtualhost basis.
1112 The collection of extended status information can slow down
1113 the server. Also note that this setting cannot be changed
1114 during a graceful restart.</p>
1117 <p>Note that loading <module>mod_status</module> will change
1118 the default behavior to ExtendedStatus On, while other
1119 third party modules may do the same. Such modules rely on
1120 collecting detailed information about the state of all workers.
1121 The default is changed by <module>mod_status</module> beginning
1122 with version 2.3.6; the previous default was always Off.</p>
1127 </directivesynopsis>
1130 <name>FileETag</name>
1131 <description>File attributes used to create the ETag
1132 HTTP response header for static files</description>
1133 <syntax>FileETag <var>component</var> ...</syntax>
1134 <default>FileETag INode MTime Size</default>
1135 <contextlist><context>server config</context><context>virtual host</context>
1136 <context>directory</context><context>.htaccess</context>
1138 <override>FileInfo</override>
1142 The <directive>FileETag</directive> directive configures the file
1143 attributes that are used to create the <code>ETag</code> (entity
1144 tag) response header field when the document is based on a static file.
1145 (The <code>ETag</code> value is used in cache management to save
1146 network bandwidth.) The
1147 <directive>FileETag</directive> directive allows you to choose
1148 which of these -- if any -- should be used. The recognized keywords are:
1152 <dt><strong>INode</strong></dt>
1153 <dd>The file's i-node number will be included in the calculation</dd>
1154 <dt><strong>MTime</strong></dt>
1155 <dd>The date and time the file was last modified will be included</dd>
1156 <dt><strong>Size</strong></dt>
1157 <dd>The number of bytes in the file will be included</dd>
1158 <dt><strong>All</strong></dt>
1159 <dd>All available fields will be used. This is equivalent to:
1160 <example>FileETag INode MTime Size</example></dd>
1161 <dt><strong>None</strong></dt>
1162 <dd>If a document is file-based, no <code>ETag</code> field will be
1163 included in the response</dd>
1166 <p>The <code>INode</code>, <code>MTime</code>, and <code>Size</code>
1167 keywords may be prefixed with either <code>+</code> or <code>-</code>,
1168 which allow changes to be made to the default setting inherited
1169 from a broader scope. Any keyword appearing without such a prefix
1170 immediately and completely cancels the inherited setting.</p>
1172 <p>If a directory's configuration includes
1173 <code>FileETag INode MTime Size</code>, and a
1174 subdirectory's includes <code>FileETag -INode</code>,
1175 the setting for that subdirectory (which will be inherited by
1176 any sub-subdirectories that don't override it) will be equivalent to
1177 <code>FileETag MTime Size</code>.</p>
1178 <note type="warning"><title>Warning</title>
1179 Do not change the default for directories or locations that have WebDAV
1180 enabled and use <module>mod_dav_fs</module> as a storage provider.
1181 <module>mod_dav_fs</module> uses <code>INode MTime Size</code>
1182 as a fixed format for <code>ETag</code> comparisons on conditional requests.
1183 These conditional requests will break if the <code>ETag</code> format is
1184 changed via <directive>FileETag</directive>.
1186 <note><title>Server Side Includes</title>
1187 An ETag is not generated for responses parsed by <module>mod_include</module>,
1188 since the response entity can change without a change of the INode, MTime, or Size
1189 of the static file with embedded SSI directives.
1193 </directivesynopsis>
1195 <directivesynopsis type="section">
1197 <description>Contains directives that apply to matched
1198 filenames</description>
1199 <syntax><Files <var>filename</var>> ... </Files></syntax>
1200 <contextlist><context>server config</context><context>virtual host</context>
1201 <context>directory</context><context>.htaccess</context>
1203 <override>All</override>
1206 <p>The <directive type="section">Files</directive> directive
1207 limits the scope of the enclosed directives by filename. It is comparable
1208 to the <directive module="core" type="section">Directory</directive>
1209 and <directive module="core" type="section">Location</directive>
1210 directives. It should be matched with a <code></Files></code>
1211 directive. The directives given within this section will be applied to
1212 any object with a basename (last component of filename) matching the
1213 specified filename. <directive type="section">Files</directive>
1214 sections are processed in the order they appear in the
1215 configuration file, after the <directive module="core"
1216 type="section">Directory</directive> sections and
1217 <code>.htaccess</code> files are read, but before <directive
1218 type="section" module="core">Location</directive> sections. Note
1219 that <directive type="section">Files</directive> can be nested
1220 inside <directive type="section"
1221 module="core">Directory</directive> sections to restrict the
1222 portion of the filesystem they apply to.</p>
1224 <p>The <var>filename</var> argument should include a filename, or
1225 a wild-card string, where <code>?</code> matches any single character,
1226 and <code>*</code> matches any sequences of characters.
1227 <glossary ref="regex">Regular expressions</glossary>
1228 can also be used, with the addition of the
1229 <code>~</code> character. For example:</p>
1232 <Files ~ "\.(gif|jpe?g|png)$">
1235 <p>would match most common Internet graphics formats. <directive
1236 module="core" type="section">FilesMatch</directive> is preferred,
1239 <p>Note that unlike <directive type="section"
1240 module="core">Directory</directive> and <directive type="section"
1241 module="core">Location</directive> sections, <directive
1242 type="section">Files</directive> sections can be used inside
1243 <code>.htaccess</code> files. This allows users to control access to
1244 their own files, at a file-by-file level.</p>
1247 <seealso><a href="../sections.html">How <Directory>, <Location>
1248 and <Files> sections work</a> for an explanation of how these
1249 different sections are combined when a request is received</seealso>
1250 </directivesynopsis>
1252 <directivesynopsis type="section">
1253 <name>FilesMatch</name>
1254 <description>Contains directives that apply to regular-expression matched
1255 filenames</description>
1256 <syntax><FilesMatch <var>regex</var>> ... </FilesMatch></syntax>
1257 <contextlist><context>server config</context><context>virtual host</context>
1258 <context>directory</context><context>.htaccess</context>
1260 <override>All</override>
1263 <p>The <directive type="section">FilesMatch</directive> directive
1264 limits the scope of the enclosed directives by filename, just as the
1265 <directive module="core" type="section">Files</directive> directive
1266 does. However, it accepts a <glossary ref="regex">regular
1267 expression</glossary>. For example:</p>
1270 <FilesMatch "\.(gif|jpe?g|png)$">
1273 <p>would match most common Internet graphics formats.</p>
1276 <seealso><a href="../sections.html">How <Directory>, <Location>
1277 and <Files> sections work</a> for an explanation of how these
1278 different sections are combined when a request is received</seealso>
1279 </directivesynopsis>
1282 <name>ForceType</name>
1283 <description>Forces all matching files to be served with the specified
1284 media type in the HTTP Content-Type header field</description>
1285 <syntax>ForceType <var>media-type</var>|None</syntax>
1286 <contextlist><context>directory</context><context>.htaccess</context>
1288 <override>FileInfo</override>
1289 <compatibility>Moved to the core in Apache httpd 2.0</compatibility>
1292 <p>When placed into an <code>.htaccess</code> file or a
1293 <directive type="section" module="core">Directory</directive>, or
1294 <directive type="section" module="core">Location</directive> or
1295 <directive type="section" module="core">Files</directive>
1296 section, this directive forces all matching files to be served
1297 with the content type identification given by
1298 <var>media-type</var>. For example, if you had a directory full of
1299 GIF files, but did not want to label them all with <code>.gif</code>,
1300 you might want to use:</p>
1306 <p>Note that this directive overrides other indirect media type
1307 associations defined in mime.types or via the
1308 <directive module="mod_mime">AddType</directive>.</p>
1310 <p>You can also override more general
1311 <directive>ForceType</directive> settings
1312 by using the value of <code>None</code>:</p>
1315 # force all files to be image/gif:<br />
1316 <Location /images><br />
1318 ForceType image/gif<br />
1320 </Location><br />
1322 # but normal mime-type associations here:<br />
1323 <Location /images/mixed><br />
1325 ForceType None<br />
1330 </directivesynopsis>
1333 <name>HostnameLookups</name>
1334 <description>Enables DNS lookups on client IP addresses</description>
1335 <syntax>HostnameLookups On|Off|Double</syntax>
1336 <default>HostnameLookups Off</default>
1337 <contextlist><context>server config</context><context>virtual host</context>
1338 <context>directory</context></contextlist>
1341 <p>This directive enables DNS lookups so that host names can be
1342 logged (and passed to CGIs/SSIs in <code>REMOTE_HOST</code>).
1343 The value <code>Double</code> refers to doing double-reverse
1344 DNS lookup. That is, after a reverse lookup is performed, a forward
1345 lookup is then performed on that result. At least one of the IP
1346 addresses in the forward lookup must match the original
1347 address. (In "tcpwrappers" terminology this is called
1348 <code>PARANOID</code>.)</p>
1350 <p>Regardless of the setting, when <module>mod_authz_host</module> is
1351 used for controlling access by hostname, a double reverse lookup
1352 will be performed. This is necessary for security. Note that the
1353 result of this double-reverse isn't generally available unless you
1354 set <code>HostnameLookups Double</code>. For example, if only
1355 <code>HostnameLookups On</code> and a request is made to an object
1356 that is protected by hostname restrictions, regardless of whether
1357 the double-reverse fails or not, CGIs will still be passed the
1358 single-reverse result in <code>REMOTE_HOST</code>.</p>
1360 <p>The default is <code>Off</code> in order to save the network
1361 traffic for those sites that don't truly need the reverse
1362 lookups done. It is also better for the end users because they
1363 don't have to suffer the extra latency that a lookup entails.
1364 Heavily loaded sites should leave this directive
1365 <code>Off</code>, since DNS lookups can take considerable
1366 amounts of time. The utility <program>logresolve</program>, compiled by
1367 default to the <code>bin</code> subdirectory of your installation
1368 directory, can be used to look up host names from logged IP addresses
1371 </directivesynopsis>
1373 <directivesynopsis type="section">
1375 <description>Contains directives that apply only if a condition is
1376 satisfied by a request at runtime</description>
1377 <syntax><If <var>expression</var>> ... </If></syntax>
1378 <contextlist><context>server config</context><context>virtual host</context>
1379 <context>directory</context><context>.htaccess</context>
1381 <override>All</override>
1384 <p>The <directive type="section">If</directive> directive
1385 evaluates an expression at runtime, and applies the enclosed
1386 directives if and only if the expression evaluates to true.
1390 <If "$req{Host} = ''">
1393 <p>would match HTTP/1.0 requests without a <var>Host:</var> header.</p>
1395 <p>You may compare the value of any variable in the request headers
1396 ($req), response headers ($resp) or environment ($env) in your
1400 <seealso><a href="../sections.html">How <Directory>, <Location>,
1401 <Files> sections work</a> for an explanation of how these
1402 different sections are combined when a request is received.
1403 <directive type="section">If</directive> has the same precedence
1404 and usage as <directive type="section">Files</directive></seealso>
1405 </directivesynopsis>
1407 <directivesynopsis type="section">
1408 <name>IfDefine</name>
1409 <description>Encloses directives that will be processed only
1410 if a test is true at startup</description>
1411 <syntax><IfDefine [!]<var>parameter-name</var>> ...
1412 </IfDefine></syntax>
1413 <contextlist><context>server config</context><context>virtual host</context>
1414 <context>directory</context><context>.htaccess</context>
1416 <override>All</override>
1419 <p>The <code><IfDefine <var>test</var>>...</IfDefine>
1420 </code> section is used to mark directives that are conditional. The
1421 directives within an <directive type="section">IfDefine</directive>
1422 section are only processed if the <var>test</var> is true. If <var>
1423 test</var> is false, everything between the start and end markers is
1426 <p>The <var>test</var> in the <directive type="section"
1427 >IfDefine</directive> section directive can be one of two forms:</p>
1430 <li><var>parameter-name</var></li>
1432 <li><code>!</code><var>parameter-name</var></li>
1435 <p>In the former case, the directives between the start and end
1436 markers are only processed if the parameter named
1437 <var>parameter-name</var> is defined. The second format reverses
1438 the test, and only processes the directives if
1439 <var>parameter-name</var> is <strong>not</strong> defined.</p>
1441 <p>The <var>parameter-name</var> argument is a define as given on the
1442 <program>httpd</program> command line via <code>-D<var>parameter</var>
1443 </code> at the time the server was started or by the <directive
1444 module="core">Define</directive> directive.</p>
1446 <p><directive type="section">IfDefine</directive> sections are
1447 nest-able, which can be used to implement simple
1448 multiple-parameter tests. Example:</p>
1451 httpd -DReverseProxy -DUseCache -DMemCache ...<br />
1454 <IfDefine ReverseProxy><br />
1456 LoadModule proxy_module modules/mod_proxy.so<br />
1457 LoadModule proxy_http_module modules/mod_proxy_http.so<br />
1458 <IfDefine UseCache><br />
1460 LoadModule cache_module modules/mod_cache.so<br />
1461 <IfDefine MemCache><br />
1463 LoadModule mem_cache_module modules/mod_mem_cache.so<br />
1465 </IfDefine><br />
1466 <IfDefine !MemCache><br />
1468 LoadModule disk_cache_module modules/mod_disk_cache.so<br />
1477 </directivesynopsis>
1479 <directivesynopsis type="section">
1480 <name>IfModule</name>
1481 <description>Encloses directives that are processed conditional on the
1482 presence or absence of a specific module</description>
1483 <syntax><IfModule [!]<var>module-file</var>|<var>module-identifier</var>> ...
1484 </IfModule></syntax>
1485 <contextlist><context>server config</context><context>virtual host</context>
1486 <context>directory</context><context>.htaccess</context>
1488 <override>All</override>
1489 <compatibility>Module identifiers are available in version 2.1 and
1490 later.</compatibility>
1493 <p>The <code><IfModule <var>test</var>>...</IfModule></code>
1494 section is used to mark directives that are conditional on the presence of
1495 a specific module. The directives within an <directive type="section"
1496 >IfModule</directive> section are only processed if the <var>test</var>
1497 is true. If <var>test</var> is false, everything between the start and
1498 end markers is ignored.</p>
1500 <p>The <var>test</var> in the <directive type="section"
1501 >IfModule</directive> section directive can be one of two forms:</p>
1504 <li><var>module</var></li>
1506 <li>!<var>module</var></li>
1509 <p>In the former case, the directives between the start and end
1510 markers are only processed if the module named <var>module</var>
1511 is included in Apache httpd -- either compiled in or
1512 dynamically loaded using <directive module="mod_so"
1513 >LoadModule</directive>. The second format reverses the test,
1514 and only processes the directives if <var>module</var> is
1515 <strong>not</strong> included.</p>
1517 <p>The <var>module</var> argument can be either the module identifier or
1518 the file name of the module, at the time it was compiled. For example,
1519 <code>rewrite_module</code> is the identifier and
1520 <code>mod_rewrite.c</code> is the file name. If a module consists of
1521 several source files, use the name of the file containing the string
1522 <code>STANDARD20_MODULE_STUFF</code>.</p>
1524 <p><directive type="section">IfModule</directive> sections are
1525 nest-able, which can be used to implement simple multiple-module
1528 <note>This section should only be used if you need to have one
1529 configuration file that works whether or not a specific module
1530 is available. In normal operation, directives need not be
1531 placed in <directive type="section">IfModule</directive>
1534 </directivesynopsis>
1537 <name>Include</name>
1538 <description>Includes other configuration files from within
1539 the server configuration files</description>
1540 <syntax>Include [<var>optional</var>|<var>strict</var>] <var>file-path</var>|<var>directory-path</var>|<var>wildcard</var></syntax>
1541 <contextlist><context>server config</context><context>virtual host</context>
1542 <context>directory</context>
1544 <compatibility>Wildcard matching available in 2.0.41 and later, directory
1545 wildcard matching available in 2.3.6 and later</compatibility>
1548 <p>This directive allows inclusion of other configuration files
1549 from within the server configuration files.</p>
1551 <p>Shell-style (<code>fnmatch()</code>) wildcard characters can be used
1552 in the filename or directory parts of the path to include several files
1553 at once, in alphabetical order. In addition, if
1554 <directive>Include</directive> points to a directory, rather than a file,
1555 Apache httpd will read all files in that directory and any subdirectory.
1556 However, including entire directories is not recommended, because it is
1557 easy to accidentally leave temporary files in a directory that can cause
1558 <program>httpd</program> to fail. Instead, we encourage you to use the
1559 wildcard syntax shown below, to include files that match a particular
1560 pattern, such as *.conf, for example.</p>
1562 <p>When a wildcard is specified for a <strong>file</strong> component of
1563 the path, and no file matches the wildcard, the
1564 <directive module="core">Include</directive>
1565 directive will be <strong>silently ignored</strong>. When a wildcard is
1566 specified for a <strong>directory</strong> component of the path, and
1567 no directory matches the wildcard, the
1568 <directive module="core">Include</directive> directive will
1569 <strong>fail with an error</strong> saying the directory cannot be found.
1572 <p>For further control over the behaviour of the server when no files or
1573 directories match, prefix the path with the modifiers <var>optional</var>
1574 or <var>strict</var>. If <var>optional</var> is specified, any wildcard
1575 file or directory that does not match will be silently ignored. If
1576 <var>strict</var> is specified, any wildcard file or directory that does
1577 not match at least one file will cause server startup to fail.</p>
1579 <p>When a directory or file component of the path is
1580 specified exactly, and that directory or file does not exist,
1581 <directive module="core">Include</directive> directive will fail with an
1582 error saying the file or directory cannot be found.</p>
1584 <p>The file path specified may be an absolute path, or may be relative
1585 to the <directive module="core">ServerRoot</directive> directory.</p>
1590 Include /usr/local/apache2/conf/ssl.conf<br />
1591 Include /usr/local/apache2/conf/vhosts/*.conf
1594 <p>Or, providing paths relative to your <directive
1595 module="core">ServerRoot</directive> directory:</p>
1598 Include conf/ssl.conf<br />
1599 Include conf/vhosts/*.conf
1602 <p>Wildcards may be included in the directory or file portion of the
1603 path. In the following example, the server will fail to load if no
1604 directories match conf/vhosts/*, but will load successfully if no
1605 files match *.conf.</p>
1608 Include conf/vhosts/*/vhost.conf<br />
1609 Include conf/vhosts/*/*.conf
1612 <p>In this example, the server will fail to load if either
1613 conf/vhosts/* matches no directories, or if *.conf matches no files:</p>
1616 Include strict conf/vhosts/*/*.conf
1619 <p>In this example, the server load successfully if either conf/vhosts/*
1620 matches no directories, or if *.conf matches no files:</p>
1623 Include optional conf/vhosts/*/*.conf
1628 <seealso><program>apachectl</program></seealso>
1629 </directivesynopsis>
1632 <name>KeepAlive</name>
1633 <description>Enables HTTP persistent connections</description>
1634 <syntax>KeepAlive On|Off</syntax>
1635 <default>KeepAlive On</default>
1636 <contextlist><context>server config</context><context>virtual host</context>
1640 <p>The Keep-Alive extension to HTTP/1.0 and the persistent
1641 connection feature of HTTP/1.1 provide long-lived HTTP sessions
1642 which allow multiple requests to be sent over the same TCP
1643 connection. In some cases this has been shown to result in an
1644 almost 50% speedup in latency times for HTML documents with
1645 many images. To enable Keep-Alive connections, set
1646 <code>KeepAlive On</code>.</p>
1648 <p>For HTTP/1.0 clients, Keep-Alive connections will only be
1649 used if they are specifically requested by a client. In
1650 addition, a Keep-Alive connection with an HTTP/1.0 client can
1651 only be used when the length of the content is known in
1652 advance. This implies that dynamic content such as CGI output,
1653 SSI pages, and server-generated directory listings will
1654 generally not use Keep-Alive connections to HTTP/1.0 clients.
1655 For HTTP/1.1 clients, persistent connections are the default
1656 unless otherwise specified. If the client requests it, chunked
1657 encoding will be used in order to send content of unknown
1658 length over persistent connections.</p>
1660 <p>When a client uses a Keep-Alive connection it will be counted
1661 as a single "request" for the <directive module="mpm_common"
1662 >MaxRequestsPerChild</directive> directive, regardless
1663 of how many requests are sent using the connection.</p>
1666 <seealso><directive module="core">MaxKeepAliveRequests</directive></seealso>
1667 </directivesynopsis>
1670 <name>KeepAliveTimeout</name>
1671 <description>Amount of time the server will wait for subsequent
1672 requests on a persistent connection</description>
1673 <syntax>KeepAliveTimeout <var>num</var>[ms]</syntax>
1674 <default>KeepAliveTimeout 5</default>
1675 <contextlist><context>server config</context><context>virtual host</context>
1677 <compatibility>Specifying a value in milliseconds is available in
1678 Apache httpd 2.3.2 and later</compatibility>
1681 <p>The number of seconds Apache httpd will wait for a subsequent
1682 request before closing the connection. By adding a postfix of ms the
1683 timeout can be also set in milliseconds. Once a request has been
1684 received, the timeout value specified by the
1685 <directive module="core">Timeout</directive> directive applies.</p>
1687 <p>Setting <directive>KeepAliveTimeout</directive> to a high value
1688 may cause performance problems in heavily loaded servers. The
1689 higher the timeout, the more server processes will be kept
1690 occupied waiting on connections with idle clients.</p>
1692 <p>In a name-based virtual host context, the value of the first
1693 defined virtual host (the default host) in a set of <directive
1694 module="core">NameVirtualHost</directive> will be used.
1695 The other values will be ignored.</p>
1697 </directivesynopsis>
1699 <directivesynopsis type="section">
1701 <description>Restrict enclosed access controls to only certain HTTP
1702 methods</description>
1703 <syntax><Limit <var>method</var> [<var>method</var>] ... > ...
1704 </Limit></syntax>
1705 <contextlist><context>directory</context><context>.htaccess</context>
1707 <override>AuthConfig, Limit</override>
1710 <p>Access controls are normally effective for
1711 <strong>all</strong> access methods, and this is the usual
1712 desired behavior. <strong>In the general case, access control
1713 directives should not be placed within a
1714 <directive type="section">Limit</directive> section.</strong></p>
1716 <p>The purpose of the <directive type="section">Limit</directive>
1717 directive is to restrict the effect of the access controls to the
1718 nominated HTTP methods. For all other methods, the access
1719 restrictions that are enclosed in the <directive
1720 type="section">Limit</directive> bracket <strong>will have no
1721 effect</strong>. The following example applies the access control
1722 only to the methods <code>POST</code>, <code>PUT</code>, and
1723 <code>DELETE</code>, leaving all other methods unprotected:</p>
1726 <Limit POST PUT DELETE><br />
1728 Require valid-user<br />
1733 <p>The method names listed can be one or more of: <code>GET</code>,
1734 <code>POST</code>, <code>PUT</code>, <code>DELETE</code>,
1735 <code>CONNECT</code>, <code>OPTIONS</code>,
1736 <code>PATCH</code>, <code>PROPFIND</code>, <code>PROPPATCH</code>,
1737 <code>MKCOL</code>, <code>COPY</code>, <code>MOVE</code>,
1738 <code>LOCK</code>, and <code>UNLOCK</code>. <strong>The method name is
1739 case-sensitive.</strong> If <code>GET</code> is used it will also
1740 restrict <code>HEAD</code> requests. The <code>TRACE</code> method
1741 cannot be limited (see <directive module="core"
1742 >TraceEnable</directive>).</p>
1744 <note type="warning">A <directive type="section"
1745 module="core">LimitExcept</directive> section should always be
1746 used in preference to a <directive type="section">Limit</directive>
1747 section when restricting access, since a <directive type="section"
1748 module="core">LimitExcept</directive> section provides protection
1749 against arbitrary methods.</note>
1751 <p>The <directive type="section">Limit</directive> and
1752 <directive type="section" module="core">LimitExcept</directive>
1753 directives may be nested. In this case, each successive level of
1754 <directive type="section">Limit</directive> or <directive
1755 type="section" module="core">LimitExcept</directive> directives must
1756 further restrict the set of methods to which access controls apply.</p>
1758 <note type="warning">When using
1759 <directive type="section">Limit</directive> or
1760 <directive type="section">LimitExcept</directive> directives with
1761 the <directive module="mod_authz_core">Require</directive> directive,
1762 note that the first <directive module="mod_authz_core">Require</directive>
1763 to succeed authorizes the request, regardless of the presence of other
1764 <directive module="mod_authz_core">Require</directive> directives.</note>
1766 <p>For example, given the following configuration, all users will
1767 be authorized for <code>POST</code> requests, and the
1768 <code>Require group editors</code> directive will be ignored
1772 <LimitExcept GET>
1776 </LimitExcept><br />
1779 Require group editors
1784 </directivesynopsis>
1786 <directivesynopsis type="section">
1787 <name>LimitExcept</name>
1788 <description>Restrict access controls to all HTTP methods
1789 except the named ones</description>
1790 <syntax><LimitExcept <var>method</var> [<var>method</var>] ... > ...
1791 </LimitExcept></syntax>
1792 <contextlist><context>directory</context><context>.htaccess</context>
1794 <override>AuthConfig, Limit</override>
1797 <p><directive type="section">LimitExcept</directive> and
1798 <code></LimitExcept></code> are used to enclose
1799 a group of access control directives which will then apply to any
1800 HTTP access method <strong>not</strong> listed in the arguments;
1801 i.e., it is the opposite of a <directive type="section"
1802 module="core">Limit</directive> section and can be used to control
1803 both standard and nonstandard/unrecognized methods. See the
1804 documentation for <directive module="core"
1805 type="section">Limit</directive> for more details.</p>
1810 <LimitExcept POST GET><br />
1812 Require valid-user<br />
1814 </LimitExcept>
1818 </directivesynopsis>
1821 <name>LimitInternalRecursion</name>
1822 <description>Determine maximum number of internal redirects and nested
1823 subrequests</description>
1824 <syntax>LimitInternalRecursion <var>number</var> [<var>number</var>]</syntax>
1825 <default>LimitInternalRecursion 10</default>
1826 <contextlist><context>server config</context><context>virtual host</context>
1828 <compatibility>Available in Apache httpd 2.0.47 and later</compatibility>
1831 <p>An internal redirect happens, for example, when using the <directive
1832 module="mod_actions">Action</directive> directive, which internally
1833 redirects the original request to a CGI script. A subrequest is Apache httpd's
1834 mechanism to find out what would happen for some URI if it were requested.
1835 For example, <module>mod_dir</module> uses subrequests to look for the
1836 files listed in the <directive module="mod_dir">DirectoryIndex</directive>
1839 <p><directive>LimitInternalRecursion</directive> prevents the server
1840 from crashing when entering an infinite loop of internal redirects or
1841 subrequests. Such loops are usually caused by misconfigurations.</p>
1843 <p>The directive stores two different limits, which are evaluated on
1844 per-request basis. The first <var>number</var> is the maximum number of
1845 internal redirects, that may follow each other. The second <var>number</var>
1846 determines, how deep subrequests may be nested. If you specify only one
1847 <var>number</var>, it will be assigned to both limits.</p>
1849 <example><title>Example</title>
1850 LimitInternalRecursion 5
1853 </directivesynopsis>
1856 <name>LimitRequestBody</name>
1857 <description>Restricts the total size of the HTTP request body sent
1858 from the client</description>
1859 <syntax>LimitRequestBody <var>bytes</var></syntax>
1860 <default>LimitRequestBody 0</default>
1861 <contextlist><context>server config</context><context>virtual host</context>
1862 <context>directory</context><context>.htaccess</context>
1864 <override>All</override>
1867 <p>This directive specifies the number of <var>bytes</var> from 0
1868 (meaning unlimited) to 2147483647 (2GB) that are allowed in a
1871 <p>The <directive>LimitRequestBody</directive> directive allows
1872 the user to set a limit on the allowed size of an HTTP request
1873 message body within the context in which the directive is given
1874 (server, per-directory, per-file or per-location). If the client
1875 request exceeds that limit, the server will return an error
1876 response instead of servicing the request. The size of a normal
1877 request message body will vary greatly depending on the nature of
1878 the resource and the methods allowed on that resource. CGI scripts
1879 typically use the message body for retrieving form information.
1880 Implementations of the <code>PUT</code> method will require
1881 a value at least as large as any representation that the server
1882 wishes to accept for that resource.</p>
1884 <p>This directive gives the server administrator greater
1885 control over abnormal client request behavior, which may be
1886 useful for avoiding some forms of denial-of-service
1889 <p>If, for example, you are permitting file upload to a particular
1890 location, and wish to limit the size of the uploaded file to 100K,
1891 you might use the following directive:</p>
1894 LimitRequestBody 102400
1898 </directivesynopsis>
1901 <name>LimitRequestFields</name>
1902 <description>Limits the number of HTTP request header fields that
1903 will be accepted from the client</description>
1904 <syntax>LimitRequestFields <var>number</var></syntax>
1905 <default>LimitRequestFields 100</default>
1906 <contextlist><context>server config</context></contextlist>
1909 <p><var>Number</var> is an integer from 0 (meaning unlimited) to
1910 32767. The default value is defined by the compile-time
1911 constant <code>DEFAULT_LIMIT_REQUEST_FIELDS</code> (100 as
1914 <p>The <directive>LimitRequestFields</directive> directive allows
1915 the server administrator to modify the limit on the number of
1916 request header fields allowed in an HTTP request. A server needs
1917 this value to be larger than the number of fields that a normal
1918 client request might include. The number of request header fields
1919 used by a client rarely exceeds 20, but this may vary among
1920 different client implementations, often depending upon the extent
1921 to which a user has configured their browser to support detailed
1922 content negotiation. Optional HTTP extensions are often expressed
1923 using request header fields.</p>
1925 <p>This directive gives the server administrator greater
1926 control over abnormal client request behavior, which may be
1927 useful for avoiding some forms of denial-of-service attacks.
1928 The value should be increased if normal clients see an error
1929 response from the server that indicates too many fields were
1930 sent in the request.</p>
1935 LimitRequestFields 50
1939 </directivesynopsis>
1942 <name>LimitRequestFieldSize</name>
1943 <description>Limits the size of the HTTP request header allowed from the
1944 client</description>
1945 <syntax>LimitRequestFieldSize <var>bytes</var></syntax>
1946 <default>LimitRequestFieldSize 8190</default>
1947 <contextlist><context>server config</context></contextlist>
1950 <p>This directive specifies the number of <var>bytes</var>
1951 that will be allowed in an HTTP request header.</p>
1953 <p>The <directive>LimitRequestFieldSize</directive> directive
1954 allows the server administrator to reduce or increase the limit
1955 on the allowed size of an HTTP request header field. A server
1956 needs this value to be large enough to hold any one header field
1957 from a normal client request. The size of a normal request header
1958 field will vary greatly among different client implementations,
1959 often depending upon the extent to which a user has configured
1960 their browser to support detailed content negotiation. SPNEGO
1961 authentication headers can be up to 12392 bytes.</p>
1963 <p>This directive gives the server administrator greater
1964 control over abnormal client request behavior, which may be
1965 useful for avoiding some forms of denial-of-service attacks.</p>
1970 LimitRequestFieldSize 4094
1973 <note>Under normal conditions, the value should not be changed from
1977 </directivesynopsis>
1980 <name>LimitRequestLine</name>
1981 <description>Limit the size of the HTTP request line that will be accepted
1982 from the client</description>
1983 <syntax>LimitRequestLine <var>bytes</var></syntax>
1984 <default>LimitRequestLine 8190</default>
1985 <contextlist><context>server config</context></contextlist>
1988 <p>This directive sets the number of <var>bytes</var> that will be
1989 allowed on the HTTP request-line.</p>
1991 <p>The <directive>LimitRequestLine</directive> directive allows
1992 the server administrator to reduce or increase the limit on the allowed size
1993 of a client's HTTP request-line. Since the request-line consists of the
1994 HTTP method, URI, and protocol version, the
1995 <directive>LimitRequestLine</directive> directive places a
1996 restriction on the length of a request-URI allowed for a request
1997 on the server. A server needs this value to be large enough to
1998 hold any of its resource names, including any information that
1999 might be passed in the query part of a <code>GET</code> request.</p>
2001 <p>This directive gives the server administrator greater
2002 control over abnormal client request behavior, which may be
2003 useful for avoiding some forms of denial-of-service attacks.</p>
2008 LimitRequestLine 4094
2011 <note>Under normal conditions, the value should not be changed from
2014 </directivesynopsis>
2017 <name>LimitXMLRequestBody</name>
2018 <description>Limits the size of an XML-based request body</description>
2019 <syntax>LimitXMLRequestBody <var>bytes</var></syntax>
2020 <default>LimitXMLRequestBody 1000000</default>
2021 <contextlist><context>server config</context><context>virtual host</context>
2022 <context>directory</context><context>.htaccess</context></contextlist>
2023 <override>All</override>
2026 <p>Limit (in bytes) on maximum size of an XML-based request
2027 body. A value of <code>0</code> will disable any checking.</p>
2032 LimitXMLRequestBody 0
2036 </directivesynopsis>
2038 <directivesynopsis type="section">
2039 <name>Location</name>
2040 <description>Applies the enclosed directives only to matching
2042 <syntax><Location
2043 <var>URL-path</var>|<var>URL</var>> ... </Location></syntax>
2044 <contextlist><context>server config</context><context>virtual host</context>
2048 <p>The <directive type="section">Location</directive> directive
2049 limits the scope of the enclosed directives by URL. It is similar to the
2050 <directive type="section" module="core">Directory</directive>
2051 directive, and starts a subsection which is terminated with a
2052 <code></Location></code> directive. <directive
2053 type="section">Location</directive> sections are processed in the
2054 order they appear in the configuration file, after the <directive
2055 type="section" module="core">Directory</directive> sections and
2056 <code>.htaccess</code> files are read, and after the <directive
2057 type="section" module="core">Files</directive> sections.</p>
2059 <p><directive type="section">Location</directive> sections operate
2060 completely outside the filesystem. This has several consequences.
2061 Most importantly, <directive type="section">Location</directive>
2062 directives should not be used to control access to filesystem
2063 locations. Since several different URLs may map to the same
2064 filesystem location, such access controls may by circumvented.</p>
2066 <note><title>When to use <directive
2067 type="section">Location</directive></title>
2069 <p>Use <directive type="section">Location</directive> to apply
2070 directives to content that lives outside the filesystem. For
2071 content that lives in the filesystem, use <directive
2072 type="section" module="core">Directory</directive> and <directive
2073 type="section" module="core">Files</directive>. An exception is
2074 <code><Location /></code>, which is an easy way to
2075 apply a configuration to the entire server.</p>
2078 <p>For all origin (non-proxy) requests, the URL to be matched is a
2079 URL-path of the form <code>/path/</code>. <em>No scheme, hostname,
2080 port, or query string may be included.</em> For proxy requests, the
2081 URL to be matched is of the form
2082 <code>scheme://servername/path</code>, and you must include the
2085 <p>The URL may use wildcards. In a wild-card string, <code>?</code> matches
2086 any single character, and <code>*</code> matches any sequences of
2087 characters. Neither wildcard character matches a / in the URL-path.</p>
2089 <p><glossary ref="regex">Regular expressions</glossary>
2090 can also be used, with the addition of the <code>~</code>
2091 character. For example:</p>
2094 <Location ~ "/(extra|special)/data">
2097 <p>would match URLs that contained the substring <code>/extra/data</code>
2098 or <code>/special/data</code>. The directive <directive
2099 type="section" module="core">LocationMatch</directive> behaves
2100 identical to the regex version of <directive
2101 type="section">Location</directive>, and is preferred, for the
2102 simple reason that <code>~</code> is hard to distinguish from
2103 <code>-</code> in many fonts.</p>
2105 <p>The <directive type="section">Location</directive>
2106 functionality is especially useful when combined with the
2107 <directive module="core">SetHandler</directive>
2108 directive. For example, to enable status requests, but allow them
2109 only from browsers at <code>example.com</code>, you might use:</p>
2112 <Location /status><br />
2114 SetHandler server-status<br />
2115 Order Deny,Allow<br />
2117 Allow from .example.com<br />
2122 <note><title>Note about / (slash)</title>
2123 <p>The slash character has special meaning depending on where in a
2124 URL it appears. People may be used to its behavior in the filesystem
2125 where multiple adjacent slashes are frequently collapsed to a single
2126 slash (<em>i.e.</em>, <code>/home///foo</code> is the same as
2127 <code>/home/foo</code>). In URL-space this is not necessarily true.
2128 The <directive type="section" module="core">LocationMatch</directive>
2129 directive and the regex version of <directive type="section"
2130 >Location</directive> require you to explicitly specify multiple
2131 slashes if that is your intention.</p>
2133 <p>For example, <code><LocationMatch ^/abc></code> would match
2134 the request URL <code>/abc</code> but not the request URL <code>
2135 //abc</code>. The (non-regex) <directive type="section"
2136 >Location</directive> directive behaves similarly when used for
2137 proxy requests. But when (non-regex) <directive type="section"
2138 >Location</directive> is used for non-proxy requests it will
2139 implicitly match multiple slashes with a single slash. For example,
2140 if you specify <code><Location /abc/def></code> and the
2141 request is to <code>/abc//def</code> then it will match.</p>
2144 <seealso><a href="../sections.html">How <Directory>, <Location>
2145 and <Files> sections work</a> for an explanation of how these
2146 different sections are combined when a request is received.</seealso>
2147 <seealso><directive module="core">LocationMatch</directive></seealso>
2148 </directivesynopsis>
2150 <directivesynopsis type="section">
2151 <name>LocationMatch</name>
2152 <description>Applies the enclosed directives only to regular-expression
2153 matching URLs</description>
2154 <syntax><LocationMatch
2155 <var>regex</var>> ... </LocationMatch></syntax>
2156 <contextlist><context>server config</context><context>virtual host</context>
2160 <p>The <directive type="section">LocationMatch</directive> directive
2161 limits the scope of the enclosed directives by URL, in an identical manner
2162 to <directive module="core" type="section">Location</directive>. However,
2163 it takes a <glossary ref="regex">regular expression</glossary>
2164 as an argument instead of a simple string. For example:</p>
2167 <LocationMatch "/(extra|special)/data">
2170 <p>would match URLs that contained the substring <code>/extra/data</code>
2171 or <code>/special/data</code>.</p>
2174 <seealso><a href="../sections.html">How <Directory>, <Location>
2175 and <Files> sections work</a> for an explanation of how these
2176 different sections are combined when a request is received</seealso>
2177 </directivesynopsis>
2180 <name>LogLevel</name>
2181 <description>Controls the verbosity of the ErrorLog</description>
2182 <syntax>LogLevel [<var>module</var>:]<var>level</var>
2183 [<var>module</var>:<var>level</var>] ...
2185 <default>LogLevel warn</default>
2186 <contextlist><context>server config</context><context>virtual host</context>
2187 <context>directory</context>
2189 <compatibility>Per-module and per-directory configuration is available in
2190 Apache HTTP Server 2.3.6 and later</compatibility>
2193 <p><directive>LogLevel</directive> adjusts the verbosity of the
2194 messages recorded in the error logs (see <directive
2195 module="core">ErrorLog</directive> directive). The following
2196 <var>level</var>s are available, in order of decreasing
2200 <columnspec><column width=".2"/><column width=".3"/><column width=".5"/>
2203 <th><strong>Level</strong> </th>
2205 <th><strong>Description</strong> </th>
2207 <th><strong>Example</strong> </th>
2211 <td><code>emerg</code> </td>
2213 <td>Emergencies - system is unusable.</td>
2215 <td>"Child cannot open lock file. Exiting"</td>
2219 <td><code>alert</code> </td>
2221 <td>Action must be taken immediately.</td>
2223 <td>"getpwuid: couldn't determine user name from uid"</td>
2227 <td><code>crit</code> </td>
2229 <td>Critical Conditions.</td>
2231 <td>"socket: Failed to get a socket, exiting child"</td>
2235 <td><code>error</code> </td>
2237 <td>Error conditions.</td>
2239 <td>"Premature end of script headers"</td>
2243 <td><code>warn</code> </td>
2245 <td>Warning conditions.</td>
2247 <td>"child process 1234 did not exit, sending another
2252 <td><code>notice</code> </td>
2254 <td>Normal but significant condition.</td>
2256 <td>"httpd: caught SIGBUS, attempting to dump core in
2261 <td><code>info</code> </td>
2263 <td>Informational.</td>
2265 <td>"Server seems busy, (you may need to increase
2266 StartServers, or Min/MaxSpareServers)..."</td>
2270 <td><code>debug</code> </td>
2272 <td>Debug-level messages</td>
2274 <td>"Opening config file ..."</td>
2277 <td><code>trace1</code> </td>
2279 <td>Trace messages</td>
2281 <td>"proxy: FTP: control connection complete"</td>
2284 <td><code>trace2</code> </td>
2286 <td>Trace messages</td>
2288 <td>"proxy: CONNECT: sending the CONNECT request to the remote proxy"</td>
2291 <td><code>trace3</code> </td>
2293 <td>Trace messages</td>
2295 <td>"openssl: Handshake: start"</td>
2298 <td><code>trace4</code> </td>
2300 <td>Trace messages</td>
2302 <td>"read from buffered SSL brigade, mode 0, 17 bytes"</td>
2305 <td><code>trace5</code> </td>
2307 <td>Trace messages</td>
2309 <td>"map lookup FAILED: map=rewritemap key=keyname"</td>
2312 <td><code>trace6</code> </td>
2314 <td>Trace messages</td>
2316 <td>"cache lookup FAILED, forcing new map lookup"</td>
2319 <td><code>trace7</code> </td>
2321 <td>Trace messages, dumping large amounts of data</td>
2323 <td>"| 0000: 02 23 44 30 13 40 ac 34 df 3d bf 9a 19 49 39 15 |"</td>
2326 <td><code>trace8</code> </td>
2328 <td>Trace messages, dumping large amounts of data</td>
2330 <td>"| 0000: 02 23 44 30 13 40 ac 34 df 3d bf 9a 19 49 39 15 |"</td>
2334 <p>When a particular level is specified, messages from all
2335 other levels of higher significance will be reported as well.
2336 <em>E.g.</em>, when <code>LogLevel info</code> is specified,
2337 then messages with log levels of <code>notice</code> and
2338 <code>warn</code> will also be posted.</p>
2340 <p>Using a level of at least <code>crit</code> is
2349 <note><title>Note</title>
2350 <p>When logging to a regular file messages of the level
2351 <code>notice</code> cannot be suppressed and thus are always
2352 logged. However, this doesn't apply when logging is done
2353 using <code>syslog</code>.</p>
2356 <p>Specifying a level without a module name will reset the level
2357 for all modules to that level. Specifying a level with a module
2358 name will set the level for that module only. It is possible to
2359 use the module source file name, the module identifier, or the
2360 module identifier with the trailing <code>_module</code> omitted
2361 as module specification. This means the following three specifications
2365 LogLevel info ssl:warn<br />
2366 LogLevel info mod_ssl.c:warn<br />
2367 LogLevel info ssl_module:warn<br />
2370 <p>It is also possible to change the level per directory:</p>
2374 <Directory /usr/local/apache/htdocs/app><br />
2375 LogLevel debug<br />
2380 Per directory loglevel configuration only affects messages that are
2381 logged after the request has been parsed and that are associated with
2382 the request. Log messages which are associated with the connection or
2383 the server are not affected.
2386 </directivesynopsis>
2389 <name>MaxKeepAliveRequests</name>
2390 <description>Number of requests allowed on a persistent
2391 connection</description>
2392 <syntax>MaxKeepAliveRequests <var>number</var></syntax>
2393 <default>MaxKeepAliveRequests 100</default>
2394 <contextlist><context>server config</context><context>virtual host</context>
2398 <p>The <directive>MaxKeepAliveRequests</directive> directive
2399 limits the number of requests allowed per connection when
2400 <directive module="core" >KeepAlive</directive> is on. If it is
2401 set to <code>0</code>, unlimited requests will be allowed. We
2402 recommend that this setting be kept to a high value for maximum
2403 server performance.</p>
2408 MaxKeepAliveRequests 500
2411 </directivesynopsis>
2415 <description>Configures mutex mechanism and lock file directory for all
2416 or specified mutexes</description>
2417 <syntax>Mutex <var>mechanism</var> [default|<var>mutex-name</var>] ... [OmitPID]</syntax>
2418 <default>Mutex default</default>
2419 <contextlist><context>server config</context></contextlist>
2420 <compatibility>Available in Apache HTTP Server 2.3.4 and later</compatibility>
2423 <p>The <directive>Mutex</directive> directive sets the mechanism,
2424 and optionally the lock file location, that httpd and modules use
2425 to serialize access to resources. Specify <code>default</code> as
2426 the first argument to change the settings for all mutexes; specify
2427 a mutex name (see table below) as the first argument to override
2428 defaults only for that mutex.</p>
2430 <p>The <directive>Mutex</directive> directive is typically used in
2431 the following exceptional situations:</p>
2434 <li>change the mutex mechanism when the default mechanism selected
2435 by <glossary>APR</glossary> has a functional or performance
2438 <li>change the directory used by file-based mutexes when the
2439 default directory does not support locking</li>
2442 <note><title>Supported modules</title>
2443 <p>This directive only configures mutexes which have been registered
2444 with the core server using the <code>ap_mutex_register()</code> API.
2445 All modules bundled with httpd support the <directive>Mutex</directive>
2446 directive, but third-party modules may not. Consult the documentation
2447 of the third-party module, which must indicate the mutex name(s) which
2448 can be configured if this directive is supported.</p>
2451 <p>The following mutex <em>mechanisms</em> are available:</p>
2453 <li><code>default | yes</code>
2454 <p>This selects the default locking implementation, as determined by
2455 <glossary>APR</glossary>. The default locking implementation can
2456 be displayed by running <program>httpd</program> with the
2457 <code>-V</code> option.</p></li>
2459 <li><code>none | no</code>
2460 <p>This effectively disables the mutex, and is only allowed for a
2461 mutex if the module indicates that it is a valid choice. Consult the
2462 module documentation for more information.</p></li>
2464 <li><code>posixsem</code>
2465 <p>This is a mutex variant based on a Posix semaphore.</p>
2467 <note type="warning"><title>Warning</title>
2468 <p>The semaphore ownership is not recovered if a thread in the process
2469 holding the mutex segfaults, resulting in a hang of the web server.</p>
2473 <li><code>sysvsem</code>
2474 <p>This is a mutex variant based on a SystemV IPC semaphore.</p>
2476 <note type="warning"><title>Warning</title>
2477 <p>It is possible to "leak" SysV semaphores if processes crash
2478 before the semaphore is removed.</p>
2481 <note type="warning"><title>Security</title>
2482 <p>The semaphore API allows for a denial of service attack by any
2483 CGIs running under the same uid as the webserver (<em>i.e.</em>,
2484 all CGIs, unless you use something like <program>suexec</program>
2485 or <code>cgiwrapper</code>).</p>
2489 <li><code>sem</code>
2490 <p>This selects the "best" available semaphore implementation, choosing
2491 between Posix and SystemV IPC semaphores, in that order.</p></li>
2493 <li><code>pthread</code>
2494 <p>This is a mutex variant based on cross-process Posix thread
2497 <note type="warning"><title>Warning</title>
2498 <p>On most systems, if a child process terminates abnormally while
2499 holding a mutex that uses this implementation, the server will deadlock
2500 and stop responding to requests. When this occurs, the server will
2501 require a manual restart to recover.</p>
2502 <p>Solaris is a notable exception as it provides a mechanism which
2503 usually allows the mutex to be recovered after a child process
2504 terminates abnormally while holding a mutex.</p>
2505 <p>If your system implements the
2506 <code>pthread_mutexattr_setrobust_np()</code> function, you may be able
2507 to use the <code>pthread</code> option safely.</p>
2511 <li><code>fcntl:/path/to/mutex</code>
2512 <p>This is a mutex variant where a physical (lock-)file and the
2513 <code>fcntl()</code> function are used as the mutex.</p>
2515 <note type="warning"><title>Warning</title>
2516 <p>When multiple mutexes based on this mechanism are used within
2517 multi-threaded, multi-process environments, deadlock errors (EDEADLK)
2518 can be reported for valid mutex operations if <code>fcntl()</code>
2519 is not thread-aware, such as on Solaris.</p>
2523 <li><code>flock:/path/to/mutex</code>
2524 <p>This is similar to the <code>fcntl:/path/to/mutex</code> method
2525 with the exception that the <code>flock()</code> function is used to
2526 provide file locking.</p></li>
2528 <li><code>file:/path/to/mutex</code>
2529 <p>This selects the "best" available file locking implementation,
2530 choosing between <code>fcntl</code> and <code>flock</code>, in that
2534 <p>Most mechanisms are only available on selected platforms, where the
2535 underlying platform and <glossary>APR</glossary> support it. Mechanisms
2536 which aren't available on all platforms are <em>posixsem</em>,
2537 <em>sysvsem</em>, <em>sem</em>, <em>pthread</em>, <em>fcntl</em>,
2538 <em>flock</em>, and <em>file</em>.</p>
2540 <p>With the file-based mechanisms <em>fcntl</em> and <em>flock</em>,
2541 the path, if provided, is a directory where the lock file will be created.
2542 The default directory is httpd's run-time file directory relative to
2543 <directive module="core">ServerRoot</directive>. Always use a local disk
2544 filesystem for <code>/path/to/mutex</code> and never a directory residing
2545 on a NFS- or AFS-filesystem. The basename of the file will be the mutex
2546 type, an optional instance string provided by the module, and unless the
2547 <code>OmitPID</code> keyword is specified, the process id of the httpd
2548 parent process will be appended to to make the file name unique, avoiding
2549 conflicts when multiple httpd instances share a lock file directory. For
2550 example, if the mutex name is <code>mpm-accept</code> and the lock file
2551 directory is <code>/var/httpd/locks</code>, the lock file name for the
2552 httpd instance with parent process id 12345 would be
2553 <code>/var/httpd/locks/mpm-accept.12345</code>.</p>
2555 <note type="warning"><title>Security</title>
2556 <p>It is best to <em>avoid</em> putting mutex files in a world-writable
2557 directory such as <code>/var/tmp</code> because someone could create
2558 a denial of service attack and prevent the server from starting by
2559 creating a lockfile with the same name as the one the server will try
2563 <p>The following table documents the names of mutexes used by httpd
2564 and bundled modules.</p>
2566 <table border="1" style="zebra">
2570 <th>Protected resource</th>
2573 <td><code>mpm-accept</code></td>
2574 <td><module>prefork</module> and <module>worker</module> MPMs</td>
2575 <td>incoming connections, to avoid the thundering herd problem;
2576 for more information, refer to the
2577 <a href="../misc/perf-tuning.html">performance tuning</a>
2581 <td><code>authdigest-client</code></td>
2582 <td><module>mod_auth_digest</module></td>
2583 <td>client list in shared memory</td>
2586 <td><code>authdigest-opaque</code></td>
2587 <td><module>mod_auth_digest</module></td>
2588 <td>counter in shared memory</td>
2591 <td><code>ldap-cache</code></td>
2592 <td><module>mod_ldap</module></td>
2593 <td>LDAP result cache</td>
2596 <td><code>rewrite-map</code></td>
2597 <td><module>mod_rewrite</module></td>
2598 <td>communication with external mapping programs, to avoid
2599 intermixed I/O from multiple requests</td>
2602 <td><code>ssl-cache</code></td>
2603 <td><module>mod_ssl</module></td>
2604 <td>SSL session cache</td>
2607 <td><code>ssl-stapling</code></td>
2608 <td><module>mod_ssl</module></td>
2609 <td>OCSP stapling response cache</td>
2612 <td><code>watchdog-callback</code></td>
2613 <td><module>mod_watchdog</module></td>
2614 <td>callback function of a particular client module</td>
2618 <p>The <code>OmitPID</code> keyword suppresses the addition of the httpd
2619 parent process id from the lock file name.</p>
2621 <p>In the following example, the mutex mechanism for the MPM accept
2622 mutex will be changed from the compiled-in default to <code>fcntl</code>,
2623 with the associated lock file created in directory
2624 <code>/var/httpd/locks</code>. The mutex mechanism for all other mutexes
2625 will be changed from the compiled-in default to <code>sysvsem</code>.</p>
2628 Mutex default sysvsem<br />
2629 Mutex mpm-accept fcntl:/var/httpd/locks
2632 </directivesynopsis>
2635 <name>NameVirtualHost</name>
2636 <description>Designates an IP address for name-virtual
2637 hosting</description>
2638 <syntax>NameVirtualHost <var>addr</var>[:<var>port</var>]</syntax>
2639 <contextlist><context>server config</context></contextlist>
2643 <p>A single <directive>NameVirtualHost</directive> directive
2644 identifies a set of identical virtual hosts on which the server will
2645 further select from on the basis of the <em>hostname</em>
2646 requested by the client. The <directive>NameVirtualHost</directive>
2647 directive is a required directive if you want to configure
2648 <a href="../vhosts/">name-based virtual hosts</a>.</p>
2650 <p>This directive, and the corresponding <directive >VirtualHost</directive>,
2651 <em>must</em> be qualified with a port number if the server supports both HTTP
2652 and HTTPS connections.</p>
2654 <p>Although <var>addr</var> can be a hostname, it is recommended
2655 that you always use an IP address or a wildcard. A wildcard
2656 NameVirtualHost matches only virtualhosts that also have a literal wildcard
2657 as their argument.</p>
2659 <p>In cases where a firewall or other proxy receives the requests and
2660 forwards them on a different IP address to the server, you must specify the
2661 IP address of the physical interface on the machine which will be
2662 servicing the requests. </p>
2664 <p> In the example below, requests received on interface 192.0.2.1 and port 80
2665 will only select among the first two virtual hosts. Requests received on
2666 port 80 on any other interface will only select among the third and fourth
2667 virtual hosts. In the common case where the interface isn't important
2668 to the mapping, only the "*:80" NameVirtualHost and VirtualHost directives
2672 NameVirtualHost 192.0.2.1:80<br />
2673 NameVirtualHost *:80<br /><br />
2675 <VirtualHost 192.0.2.1:80><br />
2676 ServerName namebased-a.example.com<br />
2677 </VirtualHost><br />
2679 <VirtualHost 192.0.2.1:80><br />
2680 Servername namebased-b.example.com<br />
2681 </VirtualHost><br />
2683 <VirtualHost *:80><br />
2684 ServerName namebased-c.example.com <br />
2685 </VirtualHost><br />
2687 <VirtualHost *:80><br />
2688 ServerName namebased-d.example.com <br />
2689 </VirtualHost><br />
2694 <p>IPv6 addresses must be enclosed in square brackets, as shown
2695 in the following example:</p>
2698 NameVirtualHost [2001:db8::a00:20ff:fea7:ccea]:8080
2701 <note><title>Argument to <directive type="section">VirtualHost</directive>
2703 <p>Note that the argument to the <directive
2704 type="section">VirtualHost</directive> directive must
2705 exactly match the argument to the <directive
2706 >NameVirtualHost</directive> directive.</p>
2709 NameVirtualHost 192.0.2.2:80<br />
2710 <VirtualHost 192.0.2.2:80><br />
2712 </VirtualHost><br />
2717 <seealso><a href="../vhosts/">Virtual Hosts
2718 documentation</a></seealso>
2720 </directivesynopsis>
2723 <name>Options</name>
2724 <description>Configures what features are available in a particular
2725 directory</description>
2727 [+|-]<var>option</var> [[+|-]<var>option</var>] ...</syntax>
2728 <default>Options All</default>
2729 <contextlist><context>server config</context><context>virtual host</context>
2730 <context>directory</context><context>.htaccess</context>
2732 <override>Options</override>
2735 <p>The <directive>Options</directive> directive controls which
2736 server features are available in a particular directory.</p>
2738 <p><var>option</var> can be set to <code>None</code>, in which
2739 case none of the extra features are enabled, or one or more of
2743 <dt><code>All</code></dt>
2745 <dd>All options except for <code>MultiViews</code>. This is the default
2748 <dt><code>ExecCGI</code></dt>
2751 Execution of CGI scripts using <module>mod_cgi</module>
2754 <dt><code>FollowSymLinks</code></dt>
2758 The server will follow symbolic links in this directory.
2760 <p>Even though the server follows the symlink it does <em>not</em>
2761 change the pathname used to match against <directive type="section"
2762 module="core">Directory</directive> sections.</p>
2763 <p>Note also, that this option <strong>gets ignored</strong> if set
2764 inside a <directive type="section" module="core">Location</directive>
2766 <p>Omitting this option should not be considered a security restriction,
2767 since symlink testing is subject to race conditions that make it
2771 <dt><code>Includes</code></dt>
2774 Server-side includes provided by <module>mod_include</module>
2777 <dt><code>IncludesNOEXEC</code></dt>
2781 Server-side includes are permitted, but the <code>#exec
2782 cmd</code> and <code>#exec cgi</code> are disabled. It is still
2783 possible to <code>#include virtual</code> CGI scripts from
2784 <directive module="mod_alias">ScriptAlias</directive>ed
2787 <dt><code>Indexes</code></dt>
2790 If a URL which maps to a directory is requested, and there
2791 is no <directive module="mod_dir">DirectoryIndex</directive>
2792 (<em>e.g.</em>, <code>index.html</code>) in that directory, then
2793 <module>mod_autoindex</module> will return a formatted listing
2794 of the directory.</dd>
2796 <dt><code>MultiViews</code></dt>
2799 <a href="../content-negotiation.html">Content negotiated</a>
2800 "MultiViews" are allowed using
2801 <module>mod_negotiation</module>.</dd>
2803 <dt><code>SymLinksIfOwnerMatch</code></dt>
2805 <dd>The server will only follow symbolic links for which the
2806 target file or directory is owned by the same user id as the
2809 <note><title>Note</title> <p>This option gets ignored if
2810 set inside a <directive module="core"
2811 type="section">Location</directive> section.</p>
2812 <p>This option should not be considered a security restriction,
2813 since symlink testing is subject to race conditions that make it
2814 circumventable.</p></note>
2818 <p>Normally, if multiple <directive>Options</directive> could
2819 apply to a directory, then the most specific one is used and
2820 others are ignored; the options are not merged. (See <a
2821 href="../sections.html#mergin">how sections are merged</a>.)
2822 However if <em>all</em> the options on the
2823 <directive>Options</directive> directive are preceded by a
2824 <code>+</code> or <code>-</code> symbol, the options are
2825 merged. Any options preceded by a <code>+</code> are added to the
2826 options currently in force, and any options preceded by a
2827 <code>-</code> are removed from the options currently in
2830 <note type="warning"><title>Warning</title>
2831 <p>Mixing <directive>Options</directive> with a <code>+</code> or
2832 <code>-</code> with those without is not valid syntax, and is likely
2833 to cause unexpected results.</p>
2836 <p>For example, without any <code>+</code> and <code>-</code> symbols:</p>
2839 <Directory /web/docs><br />
2841 Options Indexes FollowSymLinks<br />
2843 </Directory><br />
2845 <Directory /web/docs/spec><br />
2847 Options Includes<br />
2852 <p>then only <code>Includes</code> will be set for the
2853 <code>/web/docs/spec</code> directory. However if the second
2854 <directive>Options</directive> directive uses the <code>+</code> and
2855 <code>-</code> symbols:</p>
2858 <Directory /web/docs><br />
2860 Options Indexes FollowSymLinks<br />
2862 </Directory><br />
2864 <Directory /web/docs/spec><br />
2866 Options +Includes -Indexes<br />
2871 <p>then the options <code>FollowSymLinks</code> and
2872 <code>Includes</code> are set for the <code>/web/docs/spec</code>
2875 <note><title>Note</title>
2876 <p>Using <code>-IncludesNOEXEC</code> or
2877 <code>-Includes</code> disables server-side includes completely
2878 regardless of the previous setting.</p>
2881 <p>The default in the absence of any other settings is
2882 <code>All</code>.</p>
2884 </directivesynopsis>
2887 <name>RLimitCPU</name>
2888 <description>Limits the CPU consumption of processes launched
2889 by Apache httpd children</description>
2890 <syntax>RLimitCPU <var>seconds</var>|max [<var>seconds</var>|max]</syntax>
2891 <default>Unset; uses operating system defaults</default>
2892 <contextlist><context>server config</context><context>virtual host</context>
2893 <context>directory</context><context>.htaccess</context></contextlist>
2894 <override>All</override>
2897 <p>Takes 1 or 2 parameters. The first parameter sets the soft
2898 resource limit for all processes and the second parameter sets
2899 the maximum resource limit. Either parameter can be a number,
2900 or <code>max</code> to indicate to the server that the limit should
2901 be set to the maximum allowed by the operating system
2902 configuration. Raising the maximum resource limit requires that
2903 the server is running as <code>root</code>, or in the initial startup
2906 <p>This applies to processes forked off from Apache httpd children
2907 servicing requests, not the Apache httpd children themselves. This
2908 includes CGI scripts and SSI exec commands, but not any
2909 processes forked off from the Apache httpd parent such as piped
2912 <p>CPU resource limits are expressed in seconds per
2915 <seealso><directive module="core">RLimitMEM</directive></seealso>
2916 <seealso><directive module="core">RLimitNPROC</directive></seealso>
2917 </directivesynopsis>
2920 <name>RLimitMEM</name>
2921 <description>Limits the memory consumption of processes launched
2922 by Apache httpd children</description>
2923 <syntax>RLimitMEM <var>bytes</var>|max [<var>bytes</var>|max]</syntax>
2924 <default>Unset; uses operating system defaults</default>
2925 <contextlist><context>server config</context><context>virtual host</context>
2926 <context>directory</context><context>.htaccess</context></contextlist>
2927 <override>All</override>
2930 <p>Takes 1 or 2 parameters. The first parameter sets the soft
2931 resource limit for all processes and the second parameter sets
2932 the maximum resource limit. Either parameter can be a number,
2933 or <code>max</code> to indicate to the server that the limit should
2934 be set to the maximum allowed by the operating system
2935 configuration. Raising the maximum resource limit requires that
2936 the server is running as <code>root</code>, or in the initial startup
2939 <p>This applies to processes forked off from Apache httpd children
2940 servicing requests, not the Apache httpd children themselves. This
2941 includes CGI scripts and SSI exec commands, but not any
2942 processes forked off from the Apache httpd parent such as piped
2945 <p>Memory resource limits are expressed in bytes per
2948 <seealso><directive module="core">RLimitCPU</directive></seealso>
2949 <seealso><directive module="core">RLimitNPROC</directive></seealso>
2950 </directivesynopsis>
2953 <name>RLimitNPROC</name>
2954 <description>Limits the number of processes that can be launched by
2955 processes launched by Apache httpd children</description>
2956 <syntax>RLimitNPROC <var>number</var>|max [<var>number</var>|max]</syntax>
2957 <default>Unset; uses operating system defaults</default>
2958 <contextlist><context>server config</context><context>virtual host</context>
2959 <context>directory</context><context>.htaccess</context></contextlist>
2960 <override>All</override>
2963 <p>Takes 1 or 2 parameters. The first parameter sets the soft
2964 resource limit for all processes and the second parameter sets
2965 the maximum resource limit. Either parameter can be a number,
2966 or <code>max</code> to indicate to the server that the limit
2967 should be set to the maximum allowed by the operating system
2968 configuration. Raising the maximum resource limit requires that
2969 the server is running as <code>root</code>, or in the initial startup
2972 <p>This applies to processes forked off from Apache httpd children
2973 servicing requests, not the Apache httpd children themselves. This
2974 includes CGI scripts and SSI exec commands, but not any
2975 processes forked off from the Apache httpd parent such as piped
2978 <p>Process limits control the number of processes per user.</p>
2980 <note><title>Note</title>
2981 <p>If CGI processes are <strong>not</strong> running
2982 under user ids other than the web server user id, this directive
2983 will limit the number of processes that the server itself can
2984 create. Evidence of this situation will be indicated by
2985 <strong><code>cannot fork</code></strong> messages in the
2986 <code>error_log</code>.</p>
2989 <seealso><directive module="core">RLimitMEM</directive></seealso>
2990 <seealso><directive module="core">RLimitCPU</directive></seealso>
2991 </directivesynopsis>
2994 <name>ScriptInterpreterSource</name>
2995 <description>Technique for locating the interpreter for CGI
2996 scripts</description>
2997 <syntax>ScriptInterpreterSource Registry|Registry-Strict|Script</syntax>
2998 <default>ScriptInterpreterSource Script</default>
2999 <contextlist><context>server config</context><context>virtual host</context>
3000 <context>directory</context><context>.htaccess</context></contextlist>
3001 <override>FileInfo</override>
3002 <compatibility>Win32 only;
3003 option <code>Registry-Strict</code> is available in Apache HTTP Server 2.0 and
3004 later</compatibility>
3007 <p>This directive is used to control how Apache httpd finds the
3008 interpreter used to run CGI scripts. The default setting is
3009 <code>Script</code>. This causes Apache httpd to use the interpreter pointed to
3010 by the shebang line (first line, starting with <code>#!</code>) in the
3011 script. On Win32 systems this line usually looks like:</p>
3014 #!C:/Perl/bin/perl.exe
3017 <p>or, if <code>perl</code> is in the <code>PATH</code>, simply:</p>
3023 <p>Setting <code>ScriptInterpreterSource Registry</code> will
3024 cause the Windows Registry tree <code>HKEY_CLASSES_ROOT</code> to be
3025 searched using the script file extension (e.g., <code>.pl</code>) as a
3026 search key. The command defined by the registry subkey
3027 <code>Shell\ExecCGI\Command</code> or, if it does not exist, by the subkey
3028 <code>Shell\Open\Command</code> is used to open the script file. If the
3029 registry keys cannot be found, Apache httpd falls back to the behavior of the
3030 <code>Script</code> option.</p>
3032 <note type="warning"><title>Security</title>
3033 <p>Be careful when using <code>ScriptInterpreterSource
3034 Registry</code> with <directive
3035 module="mod_alias">ScriptAlias</directive>'ed directories, because
3036 Apache httpd will try to execute <strong>every</strong> file within this
3037 directory. The <code>Registry</code> setting may cause undesired
3038 program calls on files which are typically not executed. For
3039 example, the default open command on <code>.htm</code> files on
3040 most Windows systems will execute Microsoft Internet Explorer, so
3041 any HTTP request for an <code>.htm</code> file existing within the
3042 script directory would start the browser in the background on the
3043 server. This is a good way to crash your system within a minute or
3047 <p>The option <code>Registry-Strict</code> which is new in Apache HTTP Server
3048 2.0 does the same thing as <code>Registry</code> but uses only the
3049 subkey <code>Shell\ExecCGI\Command</code>. The
3050 <code>ExecCGI</code> key is not a common one. It must be
3051 configured manually in the windows registry and hence prevents
3052 accidental program calls on your system.</p>
3054 </directivesynopsis>
3057 <name>SeeRequestTail</name>
3058 <description>Determine if mod_status displays the first 63 characters
3059 of a request or the last 63, assuming the request itself is greater than
3060 63 chars.</description>
3061 <syntax>SeeRequestTail On|Off</syntax>
3062 <default>SeeRequestTail Off</default>
3063 <contextlist><context>server config</context></contextlist>
3064 <compatibility>Available in Apache httpd 2.2.7 and later.</compatibility>
3067 <p>mod_status with <code>ExtendedStatus On</code>
3068 displays the actual request being handled.
3069 For historical purposes, only 63 characters of the request
3070 are actually stored for display purposes. This directive
3071 controls whether the 1st 63 characters are stored (the previous
3072 behavior and the default) or if the last 63 characters are. This
3073 is only applicable, of course, if the length of the request is
3074 64 characters or greater.</p>
3076 <p>If Apache httpd is handling <code
3077 >GET /disk1/storage/apache/htdocs/images/imagestore1/food/apples.jpg HTTP/1.1</code
3078 > mod_status displays as follows:
3083 <th>Off (default)</th>
3084 <td>GET /disk1/storage/apache/htdocs/images/imagestore1/food/apples</td>
3088 <td>orage/apache/htdocs/images/imagestore1/food/apples.jpg HTTP/1.1</td>
3093 </directivesynopsis>
3096 <name>ServerAdmin</name>
3097 <description>Email address that the server includes in error
3098 messages sent to the client</description>
3099 <syntax>ServerAdmin <var>email-address</var>|<var>URL</var></syntax>
3100 <contextlist><context>server config</context><context>virtual host</context>
3104 <p>The <directive>ServerAdmin</directive> sets the contact address
3105 that the server includes in any error messages it returns to the
3106 client. If the <code>httpd</code> doesn't recognize the supplied argument
3108 assumes, that it's an <var>email-address</var> and prepends it with
3109 <code>mailto:</code> in hyperlink targets. However, it's recommended to
3110 actually use an email address, since there are a lot of CGI scripts that
3111 make that assumption. If you want to use an URL, it should point to another
3112 server under your control. Otherwise users may not be able to contact you in
3115 <p>It may be worth setting up a dedicated address for this, e.g.</p>
3118 ServerAdmin www-admin@foo.example.com
3120 <p>as users do not always mention that they are talking about the
3123 </directivesynopsis>
3126 <name>ServerAlias</name>
3127 <description>Alternate names for a host used when matching requests
3128 to name-virtual hosts</description>
3129 <syntax>ServerAlias <var>hostname</var> [<var>hostname</var>] ...</syntax>
3130 <contextlist><context>virtual host</context></contextlist>
3133 <p>The <directive>ServerAlias</directive> directive sets the
3134 alternate names for a host, for use with <a
3135 href="../vhosts/name-based.html">name-based virtual hosts</a>. The
3136 <directive>ServerAlias</directive> may include wildcards, if appropriate.</p>
3139 <VirtualHost *:80><br />
3140 ServerName server.domain.com<br />
3141 ServerAlias server server2.domain.com server2<br />
3142 ServerAlias *.example.com<br />
3144 </VirtualHost>
3147 <seealso><a href="../vhosts/">Apache HTTP Server Virtual Host documentation</a></seealso>
3148 </directivesynopsis>
3151 <name>ServerName</name>
3152 <description>Hostname and port that the server uses to identify
3153 itself</description>
3154 <syntax>ServerName [<var>scheme</var>://]<var>fully-qualified-domain-name</var>[:<var>port</var>]</syntax>
3155 <contextlist><context>server config</context><context>virtual host</context>
3159 <p>The <directive>ServerName</directive> directive sets the
3160 request scheme, hostname and
3161 port that the server uses to identify itself. This is used when
3162 creating redirection URLs. For example, if the name of the
3163 machine hosting the web server is <code>simple.example.com</code>,
3164 but the machine also has the DNS alias <code>www.example.com</code>
3165 and you wish the web server to be so identified, the following
3166 directive should be used:</p>
3169 ServerName www.example.com:80
3172 <p>If no <directive>ServerName</directive> is specified, then the
3173 server attempts to deduce the hostname by performing a reverse
3174 lookup on the IP address. If no port is specified in the
3175 <directive>ServerName</directive>, then the server will use the
3176 port from the incoming request. For optimal reliability and
3177 predictability, you should specify an explicit hostname and port
3178 using the <directive>ServerName</directive> directive.</p>
3180 <p>If you are using <a
3181 href="../vhosts/name-based.html">name-based virtual hosts</a>,
3182 the <directive>ServerName</directive> inside a
3183 <directive type="section" module="core">VirtualHost</directive>
3184 section specifies what hostname must appear in the request's
3185 <code>Host:</code> header to match this virtual host.</p>
3188 <p>Sometimes, the server runs behind a device that processes SSL,
3189 such as a reverse proxy, load balancer or SSL offload
3190 appliance. When this is the case, specify the
3191 <code>https://</code> scheme and the port number to which the
3192 clients connect in the <directive>ServerName</directive> directive
3193 to make sure that the server generates the correct
3194 self-referential URLs.
3197 <p>See the description of the
3198 <directive module="core">UseCanonicalName</directive> and
3199 <directive module="core">UseCanonicalPhysicalPort</directive> directives for
3200 settings which determine whether self-referential URLs (e.g., by the
3201 <module>mod_dir</module> module) will refer to the
3202 specified port, or to the port number given in the client's request.
3207 <seealso><a href="../dns-caveats.html">Issues Regarding DNS and
3208 Apache HTTP Server</a></seealso>
3209 <seealso><a href="../vhosts/">Apache HTTP Server virtual host
3210 documentation</a></seealso>
3211 <seealso><directive module="core">UseCanonicalName</directive></seealso>
3212 <seealso><directive module="core">UseCanonicalPhysicalPort</directive></seealso>
3213 <seealso><directive module="core">NameVirtualHost</directive></seealso>
3214 <seealso><directive module="core">ServerAlias</directive></seealso>
3215 </directivesynopsis>
3218 <name>ServerPath</name>
3219 <description>Legacy URL pathname for a name-based virtual host that
3220 is accessed by an incompatible browser</description>
3221 <syntax>ServerPath <var>URL-path</var></syntax>
3222 <contextlist><context>virtual host</context></contextlist>
3225 <p>The <directive>ServerPath</directive> directive sets the legacy
3226 URL pathname for a host, for use with <a
3227 href="../vhosts/">name-based virtual hosts</a>.</p>
3229 <seealso><a href="../vhosts/">Apache HTTP Server Virtual Host documentation</a></seealso>
3230 </directivesynopsis>
3233 <name>ServerRoot</name>
3234 <description>Base directory for the server installation</description>
3235 <syntax>ServerRoot <var>directory-path</var></syntax>
3236 <default>ServerRoot /usr/local/apache</default>
3237 <contextlist><context>server config</context></contextlist>
3240 <p>The <directive>ServerRoot</directive> directive sets the
3241 directory in which the server lives. Typically it will contain the
3242 subdirectories <code>conf/</code> and <code>logs/</code>. Relative
3243 paths in other configuration directives (such as <directive
3244 module="core">Include</directive> or <directive
3245 module="mod_so">LoadModule</directive>, for example) are taken as
3246 relative to this directory.</p>
3248 <example><title>Example</title>
3249 ServerRoot /home/httpd
3253 <seealso><a href="../invoking.html">the <code>-d</code>
3254 option to <code>httpd</code></a></seealso>
3255 <seealso><a href="../misc/security_tips.html#serverroot">the
3256 security tips</a> for information on how to properly set
3257 permissions on the <directive>ServerRoot</directive></seealso>
3258 </directivesynopsis>
3261 <name>ServerSignature</name>
3262 <description>Configures the footer on server-generated documents</description>
3263 <syntax>ServerSignature On|Off|EMail</syntax>
3264 <default>ServerSignature Off</default>
3265 <contextlist><context>server config</context><context>virtual host</context>
3266 <context>directory</context><context>.htaccess</context>
3268 <override>All</override>
3271 <p>The <directive>ServerSignature</directive> directive allows the
3272 configuration of a trailing footer line under server-generated
3273 documents (error messages, <module>mod_proxy</module> ftp directory
3274 listings, <module>mod_info</module> output, ...). The reason why you
3275 would want to enable such a footer line is that in a chain of proxies,
3276 the user often has no possibility to tell which of the chained servers
3277 actually produced a returned error message.</p>
3279 <p>The <code>Off</code>
3280 setting, which is the default, suppresses the footer line (and is
3281 therefore compatible with the behavior of Apache-1.2 and
3282 below). The <code>On</code> setting simply adds a line with the
3283 server version number and <directive
3284 module="core">ServerName</directive> of the serving virtual host,
3285 and the <code>EMail</code> setting additionally creates a
3286 "mailto:" reference to the <directive
3287 module="core">ServerAdmin</directive> of the referenced
3290 <p>After version 2.0.44, the details of the server version number
3291 presented are controlled by the <directive
3292 module="core">ServerTokens</directive> directive.</p>
3294 <seealso><directive module="core">ServerTokens</directive></seealso>
3295 </directivesynopsis>
3298 <name>ServerTokens</name>
3299 <description>Configures the <code>Server</code> HTTP response
3300 header</description>
3301 <syntax>ServerTokens Major|Minor|Min[imal]|Prod[uctOnly]|OS|Full</syntax>
3302 <default>ServerTokens Full</default>
3303 <contextlist><context>server config</context></contextlist>
3306 <p>This directive controls whether <code>Server</code> response
3307 header field which is sent back to clients includes a
3308 description of the generic OS-type of the server as well as
3309 information about compiled-in modules.</p>
3312 <dt><code>ServerTokens Full</code> (or not specified)</dt>
3314 <dd>Server sends (<em>e.g.</em>): <code>Server: Apache/2.4.1
3315 (Unix) PHP/4.2.2 MyMod/1.2</code></dd>
3317 <dt><code>ServerTokens Prod[uctOnly]</code></dt>
3319 <dd>Server sends (<em>e.g.</em>): <code>Server:
3322 <dt><code>ServerTokens Major</code></dt>
3324 <dd>Server sends (<em>e.g.</em>): <code>Server:
3325 Apache/2</code></dd>
3327 <dt><code>ServerTokens Minor</code></dt>
3329 <dd>Server sends (<em>e.g.</em>): <code>Server:
3330 Apache/2.4</code></dd>
3332 <dt><code>ServerTokens Min[imal]</code></dt>
3334 <dd>Server sends (<em>e.g.</em>): <code>Server:
3335 Apache/2.4.1</code></dd>
3337 <dt><code>ServerTokens OS</code></dt>
3339 <dd>Server sends (<em>e.g.</em>): <code>Server: Apache/2.4.1
3344 <p>This setting applies to the entire server, and cannot be
3345 enabled or disabled on a virtualhost-by-virtualhost basis.</p>
3347 <p>After version 2.0.44, this directive also controls the
3348 information presented by the <directive
3349 module="core">ServerSignature</directive> directive.</p>
3351 <note>Setting <directive>ServerTokens</directive> to less than
3352 <code>minimal</code> is not recommended because it makes it more
3353 difficult to debug interoperational problems. Also note that
3354 disabling the Server: header does nothing at all to make your
3355 server more secure; the idea of "security through obscurity"
3356 is a myth and leads to a false sense of safety.</note>
3359 <seealso><directive module="core">ServerSignature</directive></seealso>
3360 </directivesynopsis>
3363 <name>SetHandler</name>
3364 <description>Forces all matching files to be processed by a
3365 handler</description>
3366 <syntax>SetHandler <var>handler-name</var>|None</syntax>
3367 <contextlist><context>server config</context><context>virtual host</context>
3368 <context>directory</context><context>.htaccess</context>
3370 <override>FileInfo</override>
3371 <compatibility>Moved into the core in Apache httpd 2.0</compatibility>
3374 <p>When placed into an <code>.htaccess</code> file or a
3375 <directive type="section" module="core">Directory</directive> or
3376 <directive type="section" module="core">Location</directive>
3377 section, this directive forces all matching files to be parsed
3378 through the <a href="../handler.html">handler</a> given by
3379 <var>handler-name</var>. For example, if you had a directory you
3380 wanted to be parsed entirely as imagemap rule files, regardless
3381 of extension, you might put the following into an
3382 <code>.htaccess</code> file in that directory:</p>
3385 SetHandler imap-file
3388 <p>Another example: if you wanted to have the server display a
3389 status report whenever a URL of
3390 <code>http://servername/status</code> was called, you might put
3391 the following into <code>httpd.conf</code>:</p>
3394 <Location /status><br />
3396 SetHandler server-status<br />
3401 <p>You can override an earlier defined <directive>SetHandler</directive>
3402 directive by using the value <code>None</code>.</p>
3403 <p><strong>Note:</strong> because SetHandler overrides default handlers,
3404 normal behaviour such as handling of URLs ending in a slash (/) as
3405 directories or index files is suppressed.</p>
3408 <seealso><directive module="mod_mime">AddHandler</directive></seealso>
3410 </directivesynopsis>
3413 <name>SetInputFilter</name>
3414 <description>Sets the filters that will process client requests and POST
3416 <syntax>SetInputFilter <var>filter</var>[;<var>filter</var>...]</syntax>
3417 <contextlist><context>server config</context><context>virtual host</context>
3418 <context>directory</context><context>.htaccess</context>
3420 <override>FileInfo</override>
3423 <p>The <directive>SetInputFilter</directive> directive sets the
3424 filter or filters which will process client requests and POST
3425 input when they are received by the server. This is in addition to
3426 any filters defined elsewhere, including the
3427 <directive module="mod_mime">AddInputFilter</directive>
3430 <p>If more than one filter is specified, they must be separated
3431 by semicolons in the order in which they should process the
3434 <seealso><a href="../filter.html">Filters</a> documentation</seealso>
3435 </directivesynopsis>
3438 <name>SetOutputFilter</name>
3439 <description>Sets the filters that will process responses from the
3440 server</description>
3441 <syntax>SetOutputFilter <var>filter</var>[;<var>filter</var>...]</syntax>
3442 <contextlist><context>server config</context><context>virtual host</context>
3443 <context>directory</context><context>.htaccess</context>
3445 <override>FileInfo</override>
3448 <p>The <directive>SetOutputFilter</directive> directive sets the filters
3449 which will process responses from the server before they are
3450 sent to the client. This is in addition to any filters defined
3451 elsewhere, including the
3452 <directive module="mod_mime">AddOutputFilter</directive>
3455 <p>For example, the following configuration will process all files
3456 in the <code>/www/data/</code> directory for server-side
3460 <Directory /www/data/><br />
3462 SetOutputFilter INCLUDES<br />
3467 <p>If more than one filter is specified, they must be separated
3468 by semicolons in the order in which they should process the
3471 <seealso><a href="../filter.html">Filters</a> documentation</seealso>
3472 </directivesynopsis>
3475 <name>TimeOut</name>
3476 <description>Amount of time the server will wait for
3477 certain events before failing a request</description>
3478 <syntax>TimeOut <var>seconds</var></syntax>
3479 <default>TimeOut 300</default>
3480 <contextlist><context>server config</context><context>virtual host</context></contextlist>
3483 <p>The <directive>TimeOut</directive> directive defines the length
3484 of time Apache httpd will wait for I/O in various circumstances:</p>
3487 <li>When reading data from the client, the length of time to
3488 wait for a TCP packet to arrive if the read buffer is
3491 <li>When writing data to the client, the length of time to wait
3492 for an acknowledgement of a packet if the send buffer is
3495 <li>In <module>mod_cgi</module>, the length of time to wait for
3496 output from a CGI script.</li>
3498 <li>In <module>mod_ext_filter</module>, the length of time to
3499 wait for output from a filtering process.</li>
3501 <li>In <module>mod_proxy</module>, the default timeout value if
3502 <directive module="mod_proxy">ProxyTimeout</directive> is not
3507 </directivesynopsis>
3510 <name>TraceEnable</name>
3511 <description>Determines the behaviour on <code>TRACE</code>
3512 requests</description>
3513 <syntax>TraceEnable <var>[on|off|extended]</var></syntax>
3514 <default>TraceEnable on</default>
3515 <contextlist><context>server config</context></contextlist>
3516 <compatibility>Available in Apache HTTP Server 1.3.34, 2.0.55 and later</compatibility>
3519 <p>This directive overrides the behavior of <code>TRACE</code> for both
3520 the core server and <module>mod_proxy</module>. The default
3521 <code>TraceEnable on</code> permits <code>TRACE</code> requests per
3522 RFC 2616, which disallows any request body to accompany the request.
3523 <code>TraceEnable off</code> causes the core server and
3524 <module>mod_proxy</module> to return a <code>405</code> (Method not
3525 allowed) error to the client.</p>
3527 <p>Finally, for testing and diagnostic purposes only, request
3528 bodies may be allowed using the non-compliant <code>TraceEnable
3529 extended</code> directive. The core (as an origin server) will
3530 restrict the request body to 64k (plus 8k for chunk headers if
3531 <code>Transfer-Encoding: chunked</code> is used). The core will
3532 reflect the full headers and all chunk headers with the response
3533 body. As a proxy server, the request body is not restricted to 64k.</p>
3535 </directivesynopsis>
3538 <name>UnDefine</name>
3539 <description>Undefine the existence of a variable</description>
3540 <syntax>UnDefine <var>parameter-name</var></syntax>
3541 <contextlist><context>server config</context></contextlist>
3544 <p>Undoes the effect of a <directive module="core">Define</directive> or
3545 of passing a <code>-D</code> argument to <program>httpd</program>.</p>
3546 <p>This directive can be used to toggle the use of <directive module="core"
3547 type="section">IfDefine</directive> sections without needing to alter
3548 <code>-D</code> arguments in any startup scripts.</p>
3550 </directivesynopsis>
3553 <name>UseCanonicalName</name>
3554 <description>Configures how the server determines its own name and
3556 <syntax>UseCanonicalName On|Off|DNS</syntax>
3557 <default>UseCanonicalName Off</default>
3558 <contextlist><context>server config</context><context>virtual host</context>
3559 <context>directory</context></contextlist>
3562 <p>In many situations Apache httpd must construct a <em>self-referential</em>
3563 URL -- that is, a URL that refers back to the same server. With
3564 <code>UseCanonicalName On</code> Apache httpd will use the hostname and port
3565 specified in the <directive module="core">ServerName</directive>
3566 directive to construct the canonical name for the server. This name
3567 is used in all self-referential URLs, and for the values of
3568 <code>SERVER_NAME</code> and <code>SERVER_PORT</code> in CGIs.</p>
3570 <p>With <code>UseCanonicalName Off</code> Apache httpd will form
3571 self-referential URLs using the hostname and port supplied by
3572 the client if any are supplied (otherwise it will use the
3573 canonical name, as defined above). These values are the same
3574 that are used to implement <a
3575 href="../vhosts/name-based.html">name-based virtual hosts</a>,
3576 and are available with the same clients. The CGI variables
3577 <code>SERVER_NAME</code> and <code>SERVER_PORT</code> will be
3578 constructed from the client supplied values as well.</p>
3580 <p>An example where this may be useful is on an intranet server
3581 where you have users connecting to the machine using short
3582 names such as <code>www</code>. You'll notice that if the users
3583 type a shortname, and a URL which is a directory, such as
3584 <code>http://www/splat</code>, <em>without the trailing
3585 slash</em> then Apache httpd will redirect them to
3586 <code>http://www.domain.com/splat/</code>. If you have
3587 authentication enabled, this will cause the user to have to
3588 authenticate twice (once for <code>www</code> and once again
3589 for <code>www.domain.com</code> -- see <a
3590 href="http://httpd.apache.org/docs/misc/FAQ.html#prompted-twice">the
3591 FAQ on this subject for more information</a>). But if
3592 <directive>UseCanonicalName</directive> is set <code>Off</code>, then
3593 Apache httpd will redirect to <code>http://www/splat/</code>.</p>
3595 <p>There is a third option, <code>UseCanonicalName DNS</code>,
3596 which is intended for use with mass IP-based virtual hosting to
3597 support ancient clients that do not provide a
3598 <code>Host:</code> header. With this option Apache httpd does a
3599 reverse DNS lookup on the server IP address that the client
3600 connected to in order to work out self-referential URLs.</p>
3602 <note type="warning"><title>Warning</title>
3603 <p>If CGIs make assumptions about the values of <code>SERVER_NAME</code>
3604 they may be broken by this option. The client is essentially free
3605 to give whatever value they want as a hostname. But if the CGI is
3606 only using <code>SERVER_NAME</code> to construct self-referential URLs
3607 then it should be just fine.</p>
3610 <seealso><directive module="core">UseCanonicalPhysicalPort</directive></seealso>
3611 <seealso><directive module="core">ServerName</directive></seealso>
3612 <seealso><directive module="mpm_common">Listen</directive></seealso>
3613 </directivesynopsis>
3616 <name>UseCanonicalPhysicalPort</name>
3617 <description>Configures how the server determines its own name and
3619 <syntax>UseCanonicalPhysicalPort On|Off</syntax>
3620 <default>UseCanonicalPhysicalPort Off</default>
3621 <contextlist><context>server config</context><context>virtual host</context>
3622 <context>directory</context></contextlist>
3625 <p>In many situations Apache httpd must construct a <em>self-referential</em>
3626 URL -- that is, a URL that refers back to the same server. With
3627 <code>UseCanonicalPhysicalPort On</code> Apache httpd will, when
3628 constructing the canonical port for the server to honor
3629 the <directive module="core">UseCanonicalName</directive> directive,
3630 provide the actual physical port number being used by this request
3631 as a potential port. With <code>UseCanonicalPhysicalPort Off</code>
3632 Apache httpd will not ever use the actual physical port number, instead
3633 relying on all configured information to construct a valid port number.</p>
3635 <note><title>Note</title>
3636 <p>The ordering of when the physical port is used is as follows:<br /><br />
3637 <code>UseCanonicalName On</code></p>
3639 <li>Port provided in <code>Servername</code></li>
3640 <li>Physical port</li>
3641 <li>Default port</li>
3643 <code>UseCanonicalName Off | DNS</code>
3645 <li>Parsed port from <code>Host:</code> header</li>
3646 <li>Physical port</li>
3647 <li>Port provided in <code>Servername</code></li>
3648 <li>Default port</li>
3651 <p>With <code>UseCanonicalPhysicalPort Off</code>, the
3652 physical ports are removed from the ordering.</p>
3656 <seealso><directive module="core">UseCanonicalName</directive></seealso>
3657 <seealso><directive module="core">ServerName</directive></seealso>
3658 <seealso><directive module="mpm_common">Listen</directive></seealso>
3659 </directivesynopsis>
3661 <directivesynopsis type="section">
3662 <name>VirtualHost</name>
3663 <description>Contains directives that apply only to a specific
3664 hostname or IP address</description>
3665 <syntax><VirtualHost
3666 <var>addr</var>[:<var>port</var>] [<var>addr</var>[:<var>port</var>]]
3667 ...> ... </VirtualHost></syntax>
3668 <contextlist><context>server config</context></contextlist>
3671 <p><directive type="section">VirtualHost</directive> and
3672 <code></VirtualHost></code> are used to enclose a group of
3673 directives that will apply only to a particular virtual host. Any
3674 directive that is allowed in a virtual host context may be
3675 used. When the server receives a request for a document on a
3676 particular virtual host, it uses the configuration directives
3677 enclosed in the <directive type="section">VirtualHost</directive>
3678 section. <var>Addr</var> can be:</p>
3681 <li>The IP address of the virtual host;</li>
3683 <li>A fully qualified domain name for the IP address of the
3684 virtual host (not recommended);</li>
3686 <li>The character <code>*</code>, which is used only in combination with
3687 <code>NameVirtualHost *</code> to match all IP addresses; or</li>
3689 <li>The string <code>_default_</code>, which is used only
3690 with IP virtual hosting to catch unmatched IP addresses.</li>
3693 <example><title>Example</title>
3694 <VirtualHost 10.1.2.3><br />
3696 ServerAdmin webmaster@host.example.com<br />
3697 DocumentRoot /www/docs/host.example.com<br />
3698 ServerName host.example.com<br />
3699 ErrorLog logs/host.example.com-error_log<br />
3700 TransferLog logs/host.example.com-access_log<br />
3702 </VirtualHost>
3706 <p>IPv6 addresses must be specified in square brackets because
3707 the optional port number could not be determined otherwise. An
3708 IPv6 example is shown below:</p>
3711 <VirtualHost [2001:db8::a00:20ff:fea7:ccea]><br />
3713 ServerAdmin webmaster@host.example.com<br />
3714 DocumentRoot /www/docs/host.example.com<br />
3715 ServerName host.example.com<br />
3716 ErrorLog logs/host.example.com-error_log<br />
3717 TransferLog logs/host.example.com-access_log<br />
3719 </VirtualHost>
3722 <p>Each Virtual Host must correspond to a different IP address,
3723 different port number or a different host name for the server,
3724 in the former case the server machine must be configured to
3725 accept IP packets for multiple addresses. (If the machine does
3726 not have multiple network interfaces, then this can be
3727 accomplished with the <code>ifconfig alias</code> command -- if
3728 your OS supports it).</p>
3730 <note><title>Note</title>
3731 <p>The use of <directive type="section">VirtualHost</directive> does
3732 <strong>not</strong> affect what addresses Apache httpd listens on. You
3733 may need to ensure that Apache httpd is listening on the correct addresses
3734 using <directive module="mpm_common">Listen</directive>.</p>
3737 <p>When using IP-based virtual hosting, the special name
3738 <code>_default_</code> can be specified in
3739 which case this virtual host will match any IP address that is
3740 not explicitly listed in another virtual host. In the absence
3741 of any <code>_default_</code> virtual host the "main" server config,
3742 consisting of all those definitions outside any VirtualHost
3743 section, is used when no IP-match occurs.</p>
3745 <p>You can specify a <code>:port</code> to change the port that is
3746 matched. If unspecified then it defaults to the same port as the
3747 most recent <directive module="mpm_common">Listen</directive>
3748 statement of the main server. You may also specify <code>:*</code>
3749 to match all ports on that address. (This is recommended when used
3750 with <code>_default_</code>.)</p>
3752 <p>A <directive module="core">ServerName</directive> should be
3753 specified inside each <directive
3754 type="section">VirtualHost</directive> block. If it is absent, the
3755 <directive module="core">ServerName</directive> from the "main"
3756 server configuration will be inherited.</p>
3758 <note type="warning"><title>Security</title>
3759 <p>See the <a href="../misc/security_tips.html">security tips</a>
3760 document for details on why your security could be compromised if the
3761 directory where log files are stored is writable by anyone other
3762 than the user that starts the server.</p>
3765 <seealso><a href="../vhosts/">Apache HTTP Server Virtual Host documentation</a></seealso>
3766 <seealso><a href="../dns-caveats.html">Issues Regarding DNS and
3767 Apache HTTP Server</a></seealso>
3768 <seealso><a href="../bind.html">Setting
3769 which addresses and ports Apache HTTP Server uses</a></seealso>
3770 <seealso><a href="../sections.html">How <Directory>, <Location>
3771 and <Files> sections work</a> for an explanation of how these
3772 different sections are combined when a request is received</seealso>
3773 </directivesynopsis>