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="mod_mime.xml.meta">
26 <description>Associates the requested filename's extensions
27 with the file's behavior (handlers and filters)
28 and content (mime-type, language, character set and
29 encoding)</description>
31 <sourcefile>mod_mime.c</sourcefile>
32 <identifier>mime_module</identifier>
35 <p>This module is used to assign content metadata to the content
36 selected for an HTTP response by mapping patterns in the
37 URI or filenames to the metadata values. For example, the filename
38 extensions of content files often define the content's Internet
39 media type, language, character set, and content-encoding. This
40 information is sent in HTTP messages containing that content and
41 used in content negotiation when selecting alternatives, such that
42 the user's preferences are respected when choosing one of several
43 possible contents to serve. See
44 <module>mod_negotiation</module> for more information
45 about <a href="../content-negotiation.html">content negotiation</a>.</p>
47 <p>The directives <directive
48 module="mod_mime">AddCharset</directive>, <directive
49 module="mod_mime">AddEncoding</directive>, <directive
50 module="mod_mime">AddLanguage</directive> and <directive
51 module="mod_mime">AddType</directive> are all used to map file
52 extensions onto the metadata for that file. Respectively
53 they set the character set, content-encoding, content-language,
54 and <glossary>media-type</glossary> (content-type) of documents. The directive <directive
55 module="mod_mime">TypesConfig</directive> is used to specify a
56 file which also maps extensions onto media types. </p>
58 <p>In addition, <module>mod_mime</module> may define the <a
59 href="../handler.html">handler</a> and <a
60 href="../filter.html">filters</a> that originate and process
61 content. The directives <directive
62 module="mod_mime">AddHandler</directive>, <directive
63 module="mod_mime">AddOutputFilter</directive>, and <directive
64 module="mod_mime">AddInputFilter</directive> control the modules
65 or scripts that serve the document. The <directive
66 module="mod_mime">MultiviewsMatch</directive> directive allows
67 <module>mod_negotiation</module> to consider these file extensions
68 to be included when testing Multiviews matches.</p>
70 <p>While <module>mod_mime</module> associates metadata
71 with filename extensions, the <module>core</module> server
72 provides directives that are used to associate all the files in a
73 given container (<em>e.g.</em>, <directive type="section"
74 module="core">Location</directive>, <directive type="section"
75 module="core">Directory</directive>, or <directive type="section"
76 module="core">Files</directive>) with particular
77 metadata. These directives include <directive
78 module="core">ForceType</directive>, <directive
79 module="core">SetHandler</directive>, <directive
80 module="core">SetInputFilter</directive>, and <directive
81 module="core">SetOutputFilter</directive>. The core directives
82 override any filename extension mappings defined in
83 <module>mod_mime</module>.</p>
85 <p>Note that changing the metadata for a file does not
86 change the value of the <code>Last-Modified</code> header.
87 Thus, previously cached copies may still be used by a client or
88 proxy, with the previous headers. If you change the
89 metadata (language, content type, character set or
90 encoding) you may need to 'touch' affected files (updating
91 their last modified date) to ensure that all visitors are
92 receive the corrected content headers.</p>
95 module="mod_mime_magic">MimeMagicFile</directive></seealso>
96 <seealso><directive module="core">AddDefaultCharset</directive></seealso>
97 <seealso><directive module="core">ForceType</directive></seealso>
98 <seealso><directive module="core">SetHandler</directive></seealso>
99 <seealso><directive module="core">SetInputFilter</directive></seealso>
100 <seealso><directive module="core">SetOutputFilter</directive></seealso>
102 <section id="multipleext"><title>Files with Multiple Extensions</title>
103 <p>Files can have more than one extension; the order of the
104 extensions is <em>normally</em> irrelevant. For example, if the
105 file <code>welcome.html.fr</code> maps onto content type
106 <code>text/html</code> and language French then the file
107 <code>welcome.fr.html</code> will map onto exactly the same
108 information. If more than one extension is given that maps onto
109 the same type of metadata, then the one to the right will
110 be used, except for languages and content encodings. For example,
111 if <code>.gif</code> maps to the <glossary>media-type</glossary>
112 <code>image/gif</code> and <code>.html</code> maps to the
113 media-type <code>text/html</code>, then the file
114 <code>welcome.gif.html</code> will be associated with the
115 media-type <code>text/html</code>.</p>
117 <p><a href="#charset-lang">Languages</a> and <a href="#contentencoding"
118 >content encodings</a> are treated accumulative, because one can assign
119 more than one language or encoding to a particular resource. For example,
120 the file <code>welcome.html.en.de</code> will be delivered with
121 <code>Content-Language: en, de</code> and <code>Content-Type:
122 text/html</code>.</p>
124 <p>Care should be taken when a file with multiple extensions
125 gets associated with both a <glossary>media-type</glossary>
126 and a handler. This will
127 usually result in the request being handled by the module associated
128 with the handler. For example, if the <code>.imap</code>
129 extension is mapped to the handler <code>imap-file</code> (from
130 <module>mod_imagemap</module>) and the <code>.html</code> extension is
131 mapped to the media-type <code>text/html</code>, then the file
132 <code>world.imap.html</code> will be associated with both the
133 <code>imap-file</code> handler and <code>text/html</code> media-type.
134 When it is processed, the <code>imap-file</code> handler will be used,
135 and so it will be treated as a <module>mod_imagemap</module> imagemap
138 <p>If you would prefer only the last dot-separated part of the
139 filename to be mapped to a particular piece of meta-data, then do
140 not use the <code>Add*</code> directives. For example, if you wish
141 to have the file <code>foo.html.cgi</code> processed as a CGI
142 script, but not the file <code>bar.cgi.html</code>, then instead
143 of using <code>AddHandler cgi-script .cgi</code>, use</p>
145 <example><title>Configure handler based on final extension only</title>
146 <highlight language="config">
147 <FilesMatch \.cgi$>
148 SetHandler cgi-script
155 <section id="contentencoding"><title>Content encoding</title>
156 <p>A file of a particular <glossary>media-type</glossary> can additionally be encoded a
157 particular way to simplify transmission over the Internet.
158 While this usually will refer to compression, such as
159 <code>gzip</code>, it can also refer to encryption, such a
160 <code>pgp</code> or to an encoding such as UUencoding, which is
161 designed for transmitting a binary file in an ASCII (text)
164 <p>The <a href="http://www.ietf.org/rfc/rfc2616.txt">HTTP/1.1
165 RFC</a>, section 14.11 puts it this way:</p>
167 <blockquote cite="http://www.ietf.org/rfc/rfc2616.txt">
168 <p>The Content-Encoding entity-header field is used as a modifier to
169 the media-type. When present, its value indicates what additional
170 content codings have been applied to the entity-body, and thus what
171 decoding mechanisms must be applied in order to obtain the media-type
172 referenced by the Content-Type header field. Content-Encoding is
173 primarily used to allow a document to be compressed without losing
174 the identity of its underlying media type.</p>
177 <p>By using more than one file extension (see <a
178 href="#multipleext">section above about multiple file
179 extensions</a>), you can indicate that a file is of a
180 particular <em>type</em>, and also has a particular
181 <em>encoding</em>. </p>
183 <p>For example, you may have a file which is a Microsoft Word
184 document, which is pkzipped to reduce its size. If the
185 <code>.doc</code> extension is associated with the Microsoft
186 Word file type, and the <code>.zip</code> extension is
187 associated with the pkzip file encoding, then the file
188 <code>Resume.doc.zip</code> would be known to be a pkzip'ed Word
191 <p>Apache sends a <code>Content-encoding</code> header with the
192 resource, in order to tell the client browser about the
195 <highlight language="config">Content-encoding: pkzip</highlight>
198 <section id="charset-lang"><title>Character sets and languages</title>
199 <p>In addition to file type and the file encoding,
200 another important piece of information is what language a
201 particular document is in, and in what character set the file
202 should be displayed. For example, the document might be written
203 in the Vietnamese alphabet, or in Cyrillic, and should be
204 displayed as such. This information, also, is transmitted in
207 <p>The character set, language, encoding and mime type are all
208 used in the process of content negotiation (See
209 <module>mod_negotiation</module>) to determine
210 which document to give to the client, when there are
211 alternative documents in more than one character set, language,
212 encoding or mime type. All filename extensions associations
213 created with <directive module="mod_mime">AddCharset</directive>,
214 <directive module="mod_mime">AddEncoding</directive>, <directive
215 module="mod_mime">AddLanguage</directive> and <directive
216 module="mod_mime">AddType</directive> directives
217 (and extensions listed in the <directive module="mod_mime_magic"
218 >MimeMagicFile</directive>) participate in this select process.
219 Filename extensions that are only associated using the <directive
220 module="mod_mime">AddHandler</directive>, <directive module="mod_mime"
221 >AddInputFilter</directive> or <directive module="mod_mime"
222 >AddOutputFilter</directive> directives may be included or excluded
223 from matching by using the <directive module="mod_mime"
224 >MultiviewsMatch</directive> directive.</p>
226 <section id="charset"><title>Charset</title>
227 <p>To convey this further information, Apache optionally sends
228 a <code>Content-Language</code> header, to specify the language
229 that the document is in, and can append additional information
230 onto the <code>Content-Type</code> header to indicate the
231 particular character set that should be used to correctly
232 render the information.</p>
235 Content-Language: en, fr
236 Content-Type: text/plain; charset=ISO-8859-1
239 <p>The language specification is the two-letter abbreviation
240 for the language. The <code>charset</code> is the name of the
241 particular character set which should be used.</p>
246 <name>AddCharset</name>
247 <description>Maps the given filename extensions to the specified content
248 charset</description>
249 <syntax>AddCharset <var>charset</var> <var>extension</var>
250 [<var>extension</var>] ...</syntax>
251 <contextlist><context>server config</context><context>virtual host</context>
252 <context>directory</context><context>.htaccess</context></contextlist>
253 <override>FileInfo</override>
256 <p>The <directive>AddCharset</directive> directive maps the given
257 filename extensions to the specified content charset (the Internet
258 registered name for a given character encoding). <var>charset</var>
259 is the <a href="http://www.iana.org/assignments/character-sets">media
260 type's charset parameter</a> for resources with filenames containing
261 <var>extension</var>. This mapping is added to any already in force,
262 overriding any mappings that already exist for the same
263 <var>extension</var>.</p>
265 <example><title>Example</title>
266 <highlight language="config">
268 AddCharset EUC-JP .euc
269 AddCharset ISO-2022-JP .jis
270 AddCharset SHIFT_JIS .sjis
274 <p>Then the document <code>xxxx.ja.jis</code> will be treated
275 as being a Japanese document whose charset is <code>ISO-2022-JP</code>
276 (as will the document <code>xxxx.jis.ja</code>). The
277 <directive>AddCharset</directive> directive is useful for both to
278 inform the client about the character encoding of the document so that
279 the document can be interpreted and displayed appropriately, and for <a
280 href="../content-negotiation.html">content negotiation</a>,
281 where the server returns one from several documents based on
282 the client's charset preference.</p>
284 <p>The <var>extension</var> argument is case-insensitive and can
285 be specified with or without a leading dot. Filenames may have <a
286 href="#multipleext">multiple extensions</a> and the
287 <var>extension</var> argument will be compared against each of
291 <seealso><module>mod_negotiation</module></seealso>
292 <seealso><directive module="core">AddDefaultCharset</directive></seealso>
296 <name>AddEncoding</name>
297 <description>Maps the given filename extensions to the specified encoding
299 <syntax>AddEncoding <var>encoding</var> <var>extension</var>
300 [<var>extension</var>] ...</syntax>
301 <contextlist><context>server config</context><context>virtual host</context>
302 <context>directory</context><context>.htaccess</context></contextlist>
303 <override>FileInfo</override>
306 <p>The <directive>AddEncoding</directive> directive maps the given
307 filename extensions to the specified HTTP content-encoding.
308 <var>encoding</var> is the HTTP content coding to append to the
309 value of the Content-Encoding header field for documents named with the
310 <var>extension</var>. This mapping is added to any already in force,
311 overriding any mappings that already exist for the same
312 <var>extension</var>.</p>
314 <example><title>Example</title>
315 <highlight language="config">
316 AddEncoding x-gzip .gz
317 AddEncoding x-compress .Z
321 <p>This will cause filenames containing the <code>.gz</code> extension
322 to be marked as encoded using the <code>x-gzip</code> encoding, and
323 filenames containing the <code>.Z</code> extension to be marked as
324 encoded with <code>x-compress</code>.</p>
326 <p>Old clients expect <code>x-gzip</code> and <code>x-compress</code>,
327 however the standard dictates that they're equivalent to
328 <code>gzip</code> and <code>compress</code> respectively. Apache does
329 content encoding comparisons by ignoring any leading <code>x-</code>.
330 When responding with an encoding Apache will use whatever form
331 (<em>i.e.</em>, <code>x-foo</code> or <code>foo</code>) the
332 client requested. If the client didn't specifically request a
333 particular form Apache will use the form given by the
334 <code>AddEncoding</code> directive. To make this long story
335 short, you should always use <code>x-gzip</code> and
336 <code>x-compress</code> for these two specific encodings. More
337 recent encodings, such as <code>deflate</code>, should be
338 specified without the <code>x-</code>.</p>
340 <p>The <var>extension</var> argument is case-insensitive and can
341 be specified with or without a leading dot. Filenames may have <a
342 href="#multipleext">multiple extensions</a> and the
343 <var>extension</var> argument will be compared against each of
349 <name>AddHandler</name>
350 <description>Maps the filename extensions to the specified
351 handler</description>
352 <syntax>AddHandler <var>handler-name</var> <var>extension</var>
353 [<var>extension</var>] ...</syntax>
354 <contextlist><context>server config</context><context>virtual host</context>
355 <context>directory</context><context>.htaccess</context></contextlist>
356 <override>FileInfo</override>
359 <p>Files having the name <var>extension</var> will be served by the
360 specified <var><a href="../handler.html">handler-name</a></var>. This
361 mapping is added to any already in force, overriding any mappings that
362 already exist for the same <var>extension</var>. For example, to
363 activate CGI scripts with the file extension <code>.cgi</code>, you
366 <highlight language="config">
367 AddHandler cgi-script .cgi
370 <p>Once that has been put into your httpd.conf file, any file containing
371 the <code>.cgi</code> extension will be treated as a CGI program.</p>
373 <p>The <var>extension</var> argument is case-insensitive and can
374 be specified with or without a leading dot. Filenames may have <a
375 href="#multipleext">multiple extensions</a> and the
376 <var>extension</var> argument will be compared against each of
379 <seealso><directive module="core">SetHandler</directive></seealso>
383 <name>AddInputFilter</name>
384 <description>Maps filename extensions to the filters that will process
385 client requests</description>
386 <syntax>AddInputFilter <var>filter</var>[;<var>filter</var>...]
387 <var>extension</var> [<var>extension</var>] ...</syntax>
388 <contextlist><context>server config</context><context>virtual host</context>
389 <context>directory</context><context>.htaccess</context></contextlist>
390 <override>FileInfo</override>
393 <p><directive>AddInputFilter</directive> maps the filename extension
394 <var>extension</var> to the <a href="../filter.html">filters</a> which
395 will process client requests and POST input when they are received by
396 the server. This is in addition to any filters defined elsewhere,
397 including the <directive module="core">SetInputFilter</directive>
398 directive. This mapping is merged over any already in force, overriding
399 any mappings that already exist for the same <var>extension</var>.</p>
401 <p>If more than one <var>filter</var> is specified, they must be separated
402 by semicolons in the order in which they should process the
403 content. The <var>filter</var> is case-insensitive.</p>
405 <p>The <var>extension</var> argument is case-insensitive and can
406 be specified with or without a leading dot. Filenames may have <a
407 href="#multipleext">multiple extensions</a> and the
408 <var>extension</var> argument will be compared against each of
412 <seealso><directive module="mod_mime">RemoveInputFilter</directive></seealso>
413 <seealso><directive module="core">SetInputFilter</directive></seealso>
417 <name>AddLanguage</name>
418 <description>Maps the given filename extension to the specified content
419 language</description>
420 <syntax>AddLanguage <var>language-tag</var> <var>extension</var>
421 [<var>extension</var>] ...</syntax>
422 <contextlist><context>server config</context><context>virtual host</context>
423 <context>directory</context><context>.htaccess</context></contextlist>
424 <override>FileInfo</override>
427 <p>The <directive>AddLanguage</directive> directive maps the given
428 filename extension to the specified content language. Files with the
429 filename <var>extension</var> are assigned an HTTP Content-Language
430 value of <var>language-tag</var> corresponding to the language
431 identifiers defined by RFC 3066.
432 This directive overrides any mappings that already exist for the same
433 <var>extension</var>.</p>
435 <example><title>Example</title>
436 <highlight language="config">
437 AddEncoding x-compress .Z
443 <p>Then the document <code>xxxx.en.Z</code> will be treated as
444 being a compressed English document (as will the document
445 <code>xxxx.Z.en</code>). Although the content language is
446 reported to the client, the browser is unlikely to use this
447 information. The <directive>AddLanguage</directive> directive is
448 more useful for <a href="../content-negotiation.html">content
449 negotiation</a>, where the server returns one from several documents
450 based on the client's language preference.</p>
452 <p>If multiple language assignments are made for the same
453 extension, the last one encountered is the one that is used.
454 That is, for the case of:</p>
456 <highlight language="config">
458 AddLanguage en-gb .en
459 AddLanguage en-us .en
462 <p>documents with the extension <code>.en</code> would be treated as
463 being <code>en-us</code>.</p>
465 <p>The <var>extension</var> argument is case-insensitive and can
466 be specified with or without a leading dot. Filenames may have <a
467 href="#multipleext">multiple extensions</a> and the
468 <var>extension</var> argument will be compared against each of
471 <seealso><module>mod_negotiation</module></seealso>
475 <name>AddOutputFilter</name>
476 <description>Maps filename extensions to the filters that will process
477 responses from the server</description>
478 <syntax>AddOutputFilter <var>filter</var>[;<var>filter</var>...]
479 <var>extension</var> [<var>extension</var>] ...</syntax>
480 <contextlist><context>server config</context><context>virtual host</context>
481 <context>directory</context><context>.htaccess</context></contextlist>
482 <override>FileInfo</override>
485 <p>The <directive>AddOutputFilter</directive> directive maps the
486 filename extension <var>extension</var> to the <a
487 href="../filter.html">filters</a> which will process responses
488 from the server before they are sent to the client. This is in
489 addition to any filters defined elsewhere, including <directive
490 module="core">SetOutputFilter</directive> and <directive module="mod_filter"
491 >AddOutputFilterByType</directive> directive. This mapping is merged
492 over any already in force, overriding any mappings that already exist
493 for the same <var>extension</var>.</p>
495 <p>For example, the following configuration will process all
496 <code>.shtml</code> files for server-side includes and will then
497 compress the output using <module>mod_deflate</module>.</p>
499 <highlight language="config">
500 AddOutputFilter INCLUDES;DEFLATE shtml
503 <p>If more than one filter is specified, they must be separated
504 by semicolons in the order in which they should process the
505 content. The <var>filter</var> argument is case-insensitive.</p>
507 <p>The <var>extension</var> argument is case-insensitive and can
508 be specified with or without a leading dot. Filenames may have <a
509 href="#multipleext">multiple extensions</a> and the
510 <var>extension</var> argument will be compared against each of
513 <p>Note that when defining a set of filters using the
514 <directive module="mod_mime">AddOutputFilter</directive> directive,
515 any definition made will replace any previous definition made by
516 the <directive module="mod_mime">AddOutputFilter</directive>
519 <highlight language="config">
520 # Effective filter "DEFLATE"
521 AddOutputFilter DEFLATE shtml
522 <Location /foo>
523 # Effective filter "INCLUDES", replacing "DEFLATE"
524 AddOutputFilter INCLUDES shtml
526 <Location /bar>
527 # Effective filter "INCLUDES;DEFLATE", replacing "DEFLATE"
528 AddOutputFilter INCLUDES;DEFLATE shtml
530 <Location /bar/baz>
531 # Effective filter "BUFFER", replacing "INCLUDES;DEFLATE"
532 AddOutputFilter BUFFER shtml
534 <Location /bar/baz/buz>
535 # No effective filter, replacing "BUFFER"
536 RemoveOutputFilter shtml
540 <seealso><directive module="mod_mime">RemoveOutputFilter</directive></seealso>
541 <seealso><directive module="core">SetOutputFilter</directive></seealso>
546 <description>Maps the given filename extensions onto the specified content
548 <syntax>AddType <var>media-type</var> <var>extension</var>
549 [<var>extension</var>] ...</syntax>
550 <contextlist><context>server config</context><context>virtual host</context>
551 <context>directory</context><context>.htaccess</context></contextlist>
552 <override>FileInfo</override>
555 <p>The <directive>AddType</directive> directive maps the given
556 filename extensions onto the specified content
557 type. <var>media-type</var> is the <glossary ref="media-type">media
558 type</glossary> to use for filenames containing
559 <var>extension</var>. This mapping is added to any already in
560 force, overriding any mappings that already exist for the same
561 <var>extension</var>.</p>
564 It is recommended that new media types be added using the
565 <directive>AddType</directive> directive rather than changing the
566 <directive module="mod_mime">TypesConfig</directive> file.
569 <example><title>Example</title>
570 <highlight language="config">
571 AddType image/gif .gif
575 <p>Or, to specify multiple file extensions in one directive:</p>
577 <example><title>Example</title>
578 <highlight language="config">
579 AddType image/jpeg jpeg jpg jpe
583 <p>The <var>extension</var> argument is case-insensitive and can
584 be specified with or without a leading dot. Filenames may have <a
585 href="#multipleext">multiple extensions</a> and the
586 <var>extension</var> argument will be compared against each of
589 <p>A simmilar effect to <module>mod_negotiation</module>'s
590 <directive module="mod_negotiation">LanguagePriority</directive>
591 can be achieved by qualifying a <var>media-type</var> with
594 <example><title>Example</title>
595 <highlight language="config">
596 AddType application/rss+xml;qs=0.8 .xml
600 <p>This is useful in situations, <em>e.g.</em> when a client
601 requesting <code>Accept: */*</code> can not actually processes
602 the content returned by the server.</p>
604 <p>This directive primarily configures the content types generated for
605 static files served out of the filesystem. For resources other than
606 static files, where the generator of the response typically specifies
607 a Content-Type, this directive has no effect.</p>
610 <seealso><directive module="core">ForceType</directive></seealso>
611 <seealso><module>mod_negotiation</module></seealso>
615 <name>MultiviewsMatch</name>
616 <description>The types of files that will be included when searching for
617 a matching file with MultiViews</description>
618 <syntax>MultiviewsMatch Any|NegotiatedOnly|Filters|Handlers
619 [Handlers|Filters]</syntax>
620 <default>MultiviewsMatch NegotiatedOnly</default>
621 <contextlist><context>server config</context><context>virtual host</context>
622 <context>directory</context><context>.htaccess</context></contextlist>
623 <override>FileInfo</override>
626 <p><directive>MultiviewsMatch</directive> permits three different
627 behaviors for <a href="mod_negotiation.html">mod_negotiation</a>'s
628 Multiviews feature. Multiviews allows a request for a file,
629 <em>e.g.</em> <code>index.html</code>, to match any negotiated
630 extensions following the base request, <em>e.g.</em>
631 <code>index.html.en</code>, <code>index.html.fr</code>, or
632 <code>index.html.gz</code>.</p>
634 <p>The <code>NegotiatedOnly</code> option provides that every extension
635 following the base name must correlate to a recognized
636 <module>mod_mime</module> extension for content negotiation, <em>e.g.</em>
637 Charset, Content-Type, Language, or Encoding. This is the strictest
638 implementation with the fewest unexpected side effects, and is the
639 default behavior.</p>
641 <p>To include extensions associated with Handlers and/or Filters,
642 set the <directive>MultiviewsMatch</directive> directive to either
643 <code>Handlers</code>, <code>Filters</code>, or both option keywords.
644 If all other factors are equal, the smallest file will be served,
645 <em>e.g.</em> in deciding between <code>index.html.cgi</code> of 500
646 bytes and <code>index.html.pl</code> of 1000 bytes, the <code>.cgi</code>
647 file would win in this example. Users of <code>.asis</code> files
648 might prefer to use the Handler option, if <code>.asis</code> files are
649 associated with the <code>asis-handler</code>.</p>
651 <p>You may finally allow <code>Any</code> extensions to match, even if
652 <module>mod_mime</module> doesn't recognize the extension. This can cause
653 unpredictable results, such as serving .old or .bak files the webmaster
654 never expected to be served.</p>
656 <p>For example, the following configuration will allow handlers
657 and filters to participate in Multviews, but will exclude unknown
660 <highlight language="config">
661 MultiviewsMatch Handlers Filters
664 <p><directive>MultiviewsMatch</directive> is not allowed in a
665 <directive type="section" module="core">Location</directive> or <directive
666 type="section" module="core">LocationMatch</directive> section.</p>
669 <seealso><directive module="core">Options</directive></seealso>
670 <seealso><module>mod_negotiation</module></seealso>
674 <name>DefaultLanguage</name>
675 <description>Defines a default language-tag to be sent in the Content-Language
676 header field for all resources in the current context that have not been
677 assigned a language-tag by some other means.</description>
678 <syntax>DefaultLanguage <var>language-tag</var></syntax>
679 <contextlist><context>server config</context><context>virtual host</context>
680 <context>directory</context><context>.htaccess</context></contextlist>
681 <override>FileInfo</override>
684 <p>The <directive>DefaultLanguage</directive> directive tells Apache
685 that all resources in the directive's scope (<em>e.g.</em>, all resources
686 covered by the current <directive module="core" type="section"
687 >Directory</directive> container) that don't have an explicit language
688 extension (such as <code>.fr</code> or <code>.de</code> as configured
689 by <directive module="mod_mime">AddLanguage</directive>) should be
690 assigned a Content-Language of <var>language-tag</var>. This allows
691 entire directory trees to be marked as containing Dutch content, for
692 instance, without having to rename each file. Note that unlike using
693 extensions to specify languages, <directive>DefaultLanguage</directive>
694 can only specify a single language.</p>
696 <p>If no <directive>DefaultLanguage</directive> directive is in force
697 and a file does not have any language extensions as configured
698 by <directive module="mod_mime">AddLanguage</directive>, then no
699 Content-Language header field will be generated.</p>
701 <example><title>Example</title>
702 <highlight language="config">
707 <seealso><module>mod_negotiation</module></seealso>
711 <name>ModMimeUsePathInfo</name>
712 <description>Tells <module>mod_mime</module> to treat <code>path_info</code>
713 components as part of the filename</description>
714 <syntax>ModMimeUsePathInfo On|Off</syntax>
715 <default>ModMimeUsePathInfo Off</default>
716 <contextlist><context>directory</context></contextlist>
719 <p>The <directive>ModMimeUsePathInfo</directive> directive is used to
720 combine the filename with the <code>path_info</code> URL component to
721 apply <module>mod_mime</module>'s directives to the request. The default
722 value is <code>Off</code> - therefore, the <code>path_info</code>
723 component is ignored.</p>
725 <p>This directive is recommended when you have a virtual filesystem.</p>
727 <example><title>Example</title>
728 <highlight language="config">
729 ModMimeUsePathInfo On
733 <p>If you have a request for <code>/index.php/foo.shtml</code>
734 <module>mod_mime</module> will now treat the
735 incoming request as <code>/index.php/foo.shtml</code> and directives
736 like <code>AddOutputFilter INCLUDES .shtml</code> will add the
737 <code>INCLUDES</code> filter to the request. If <directive
738 >ModMimeUsePathInfo</directive> is not set, the
739 <code>INCLUDES</code> filter will not be added. This will work
740 analogously for virtual paths, such as those defined by
741 <directive type="section">Location</directive></p>
743 <seealso><directive module="core">AcceptPathInfo</directive></seealso>
747 <name>RemoveCharset</name>
748 <description>Removes any character set associations for a set of file
749 extensions</description>
750 <syntax>RemoveCharset <var>extension</var> [<var>extension</var>]
752 <contextlist><context>virtual host</context><context>directory</context>
753 <context>.htaccess</context></contextlist>
754 <override>FileInfo</override>
757 <p>The <directive>RemoveCharset</directive> directive removes any
758 character set associations for files with the given extensions.
759 This allows <code>.htaccess</code> files in subdirectories to
760 undo any associations inherited from parent directories or the
761 server config files.</p>
763 <p>The <var>extension</var> argument is case-insensitive and can
764 be specified with or without a leading dot.</p>
766 <example><title>Example</title>
767 <highlight language="config">
768 RemoveCharset .html .shtml
775 <name>RemoveEncoding</name>
776 <description>Removes any content encoding associations for a set of file
777 extensions</description>
778 <syntax>RemoveEncoding <var>extension</var> [<var>extension</var>]
780 <contextlist><context>virtual host</context><context>directory</context>
781 <context>.htaccess</context></contextlist>
782 <override>FileInfo</override>
785 <p>The <directive>RemoveEncoding</directive> directive removes any
786 encoding associations for files with the given extensions. This
787 allows <code>.htaccess</code> files in subdirectories to undo
788 any associations inherited from parent directories or the
789 server config files. An example of its use might be:</p>
791 <example><title>/foo/.htaccess:</title>
792 <highlight language="config">
793 AddEncoding x-gzip .gz
794 AddType text/plain .asc
795 <Files *.gz.asc>
801 <p>This will cause <code>foo.gz</code> to be marked as being
802 encoded with the gzip method, but <code>foo.gz.asc</code> as an
803 unencoded plaintext file.</p>
805 <note><title>Note</title>
806 <p><directive>RemoveEncoding</directive> directives are processed
807 <em>after</em> any <directive module="mod_mime">AddEncoding</directive>
808 directives, so it is possible they may undo the effects of the latter
809 if both occur within the same directory configuration.</p>
812 <p>The <var>extension</var> argument is case-insensitive and can
813 be specified with or without a leading dot.</p>
818 <name>RemoveHandler</name>
819 <description>Removes any handler associations for a set of file
820 extensions</description>
821 <syntax>RemoveHandler <var>extension</var> [<var>extension</var>]
823 <contextlist><context>virtual host</context><context>directory</context>
824 <context>.htaccess</context></contextlist>
825 <override>FileInfo</override>
828 <p>The <directive>RemoveHandler</directive> directive removes any
829 handler associations for files with the given extensions. This allows
830 <code>.htaccess</code> files in subdirectories to undo any
831 associations inherited from parent directories or the server
832 config files. An example of its use might be:</p>
834 <example><title>/foo/.htaccess:</title>
835 <highlight language="config">
836 AddHandler server-parsed .html
840 <example><title>/foo/bar/.htaccess:</title>
841 <highlight language="config">
846 <p>This has the effect of returning <code>.html</code> files in
847 the <code>/foo/bar</code> directory to being treated as normal
848 files, rather than as candidates for parsing (see the <module
849 >mod_include</module> module).</p>
851 <p>The <var>extension</var> argument is case-insensitive and can
852 be specified with or without a leading dot.</p>
857 <name>RemoveInputFilter</name>
858 <description>Removes any input filter associations for a set of file
859 extensions</description>
860 <syntax>RemoveInputFilter <var>extension</var> [<var>extension</var>]
862 <contextlist><context>virtual host</context><context>directory</context>
863 <context>.htaccess</context></contextlist>
864 <override>FileInfo</override>
867 <p>The <directive>RemoveInputFilter</directive> directive removes any
868 input <a href="../filter.html">filter</a> associations for files with
869 the given extensions.
870 This allows <code>.htaccess</code> files in subdirectories to
871 undo any associations inherited from parent directories or the
872 server config files.</p>
874 <p>The <var>extension</var> argument is case-insensitive and can
875 be specified with or without a leading dot.</p>
877 <seealso><directive module="mod_mime">AddInputFilter</directive></seealso>
878 <seealso><directive module="core">SetInputFilter</directive></seealso>
882 <name>RemoveLanguage</name>
883 <description>Removes any language associations for a set of file
884 extensions</description>
885 <syntax>RemoveLanguage <var>extension</var> [<var>extension</var>]
887 <contextlist><context>virtual host</context><context>directory</context>
888 <context>.htaccess</context></contextlist>
889 <override>FileInfo</override>
892 <p>The <directive>RemoveLanguage</directive> directive removes any
893 language associations for files with the given extensions. This
894 allows <code>.htaccess</code> files in subdirectories to undo
895 any associations inherited from parent directories or the
896 server config files.</p>
898 <p>The <var>extension</var> argument is case-insensitive and can
899 be specified with or without a leading dot.</p>
904 <name>RemoveOutputFilter</name>
905 <description>Removes any output filter associations for a set of file
906 extensions</description>
907 <syntax>RemoveOutputFilter <var>extension</var> [<var>extension</var>]
909 <contextlist><context>virtual host</context><context>directory</context>
910 <context>.htaccess</context></contextlist>
911 <override>FileInfo</override>
914 <p>The <directive>RemoveOutputFilter</directive> directive removes any
915 output <a href="../filter.html">filter</a> associations for files with
916 the given extensions.
917 This allows <code>.htaccess</code> files in subdirectories to
918 undo any associations inherited from parent directories or the
919 server config files.</p>
921 <p>The <var>extension</var> argument is case-insensitive and can
922 be specified with or without a leading dot.</p>
924 <example><title>Example</title>
925 <highlight language="config">
926 RemoveOutputFilter shtml
930 <seealso><directive module="mod_mime">AddOutputFilter</directive></seealso>
934 <name>RemoveType</name>
935 <description>Removes any content type associations for a set of file
936 extensions</description>
937 <syntax>RemoveType <var>extension</var> [<var>extension</var>]
939 <contextlist><context>virtual host</context><context>directory</context>
940 <context>.htaccess</context></contextlist>
941 <override>FileInfo</override>
944 <p>The <directive>RemoveType</directive> directive removes any
945 <glossary ref="media-type">media type</glossary> associations for files with
946 the given extensions. This allows <code>.htaccess</code> files in
947 subdirectories to undo any associations inherited from parent
948 directories or the server config files. An example of its use
951 <example><title>/foo/.htaccess:</title>
952 <highlight language="config">
957 <p>This will remove any special handling of <code>.cgi</code>
958 files in the <code>/foo/</code> directory and any beneath it,
959 causing responses containing those files to omit the HTTP
960 Content-Type header field.</p>
962 <note><title>Note</title>
963 <p><directive>RemoveType</directive> directives are processed
964 <em>after</em> any <directive module="mod_mime">AddType</directive>
965 directives, so it is possible they may undo the effects of the
966 latter if both occur within the same directory configuration.</p>
969 <p>The <var>extension</var> argument is case-insensitive and can
970 be specified with or without a leading dot.</p>
975 <name>TypesConfig</name>
976 <description>The location of the <code>mime.types</code> file</description>
977 <syntax>TypesConfig <var>file-path</var></syntax>
978 <default>TypesConfig conf/mime.types</default>
979 <contextlist><context>server config</context></contextlist>
982 <p>The <directive>TypesConfig</directive> directive sets the
983 location of the <glossary ref="media-type">media types</glossary>
984 configuration file. <var>File-path</var> is relative to the
985 <directive module="core">ServerRoot</directive>. This file sets
986 the default list of mappings from filename extensions to content
987 types. Most administrators use the <code>mime.types</code> file
988 provided by their OS, which associates common filename
989 extensions with the official list of IANA registered media types
990 maintained at <a href=
991 "http://www.iana.org/assignments/media-types/index.html"
992 >http://www.iana.org/assignments/media-types/index.html</a>
993 as well as a large number of unofficial types. This
994 simplifies the <code>httpd.conf</code> file by providing the
995 majority of media-type definitions, and may be overridden by
996 <directive module="mod_mime">AddType</directive> directives as
997 needed. You should not edit the <code>mime.types</code> file,
998 because it may be replaced when you upgrade your server.</p>
1000 <p>The file contains lines in the format of the arguments to
1001 an <directive module="mod_mime">AddType</directive> directive:</p>
1004 <var>media-type</var> [<var>extension</var>] ...
1007 <p>The case of the extension does not matter. Blank lines, and lines
1008 beginning with a hash character (<code>#</code>) are ignored.
1009 Empty lines are there for completeness (of the mime.types file).
1010 Apache httpd can still determine these types with <module
1011 >mod_mime_magic</module>.
1015 Please do <strong>not</strong> send requests to the Apache HTTP
1016 Server Project to add any new entries in the distributed
1017 <code>mime.types</code> file unless (1) they are already
1018 registered with IANA, and (2) they use widely accepted,
1019 non-conflicting filename extensions across platforms.
1020 <code>category/x-subtype</code> requests will be automatically
1021 rejected, as will any new two-letter extensions as they will
1022 likely conflict later with the already crowded language and
1023 character set namespace.
1026 <seealso><module>mod_mime_magic</module></seealso>
1027 </directivesynopsis>