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>
391 <compatibility>AddInputFilter is only available in Apache 2.0.26 and
392 later.</compatibility>
395 <p><directive>AddInputFilter</directive> maps the filename extension
396 <var>extension</var> to the <a href="../filter.html">filters</a> which
397 will process client requests and POST input when they are received by
398 the server. This is in addition to any filters defined elsewhere,
399 including the <directive module="core">SetInputFilter</directive>
400 directive. This mapping is merged over any already in force, overriding
401 any mappings that already exist for the same <var>extension</var>.</p>
403 <p>If more than one <var>filter</var> is specified, they must be separated
404 by semicolons in the order in which they should process the
405 content. The <var>filter</var> is case-insensitive.</p>
407 <p>The <var>extension</var> argument is case-insensitive and can
408 be specified with or without a leading dot. Filenames may have <a
409 href="#multipleext">multiple extensions</a> and the
410 <var>extension</var> argument will be compared against each of
414 <seealso><directive module="mod_mime">RemoveInputFilter</directive></seealso>
415 <seealso><directive module="core">SetInputFilter</directive></seealso>
419 <name>AddLanguage</name>
420 <description>Maps the given filename extension to the specified content
421 language</description>
422 <syntax>AddLanguage <var>language-tag</var> <var>extension</var>
423 [<var>extension</var>] ...</syntax>
424 <contextlist><context>server config</context><context>virtual host</context>
425 <context>directory</context><context>.htaccess</context></contextlist>
426 <override>FileInfo</override>
429 <p>The <directive>AddLanguage</directive> directive maps the given
430 filename extension to the specified content language. Files with the
431 filename <var>extension</var> are assigned an HTTP Content-Language
432 value of <var>language-tag</var> corresponding to the language
433 identifiers defined by RFC 3066.
434 This directive overrides any mappings that already exist for the same
435 <var>extension</var>.</p>
437 <example><title>Example</title>
438 <highlight language="config">
439 AddEncoding x-compress .Z
445 <p>Then the document <code>xxxx.en.Z</code> will be treated as
446 being a compressed English document (as will the document
447 <code>xxxx.Z.en</code>). Although the content language is
448 reported to the client, the browser is unlikely to use this
449 information. The <directive>AddLanguage</directive> directive is
450 more useful for <a href="../content-negotiation.html">content
451 negotiation</a>, where the server returns one from several documents
452 based on the client's language preference.</p>
454 <p>If multiple language assignments are made for the same
455 extension, the last one encountered is the one that is used.
456 That is, for the case of:</p>
458 <highlight language="config">
460 AddLanguage en-gb .en
461 AddLanguage en-us .en
464 <p>documents with the extension <code>.en</code> would be treated as
465 being <code>en-us</code>.</p>
467 <p>The <var>extension</var> argument is case-insensitive and can
468 be specified with or without a leading dot. Filenames may have <a
469 href="#multipleext">multiple extensions</a> and the
470 <var>extension</var> argument will be compared against each of
473 <seealso><module>mod_negotiation</module></seealso>
477 <name>AddOutputFilter</name>
478 <description>Maps filename extensions to the filters that will process
479 responses from the server</description>
480 <syntax>AddOutputFilter <var>filter</var>[;<var>filter</var>...]
481 <var>extension</var> [<var>extension</var>] ...</syntax>
482 <contextlist><context>server config</context><context>virtual host</context>
483 <context>directory</context><context>.htaccess</context></contextlist>
484 <override>FileInfo</override>
485 <compatibility>AddOutputFilter is only available in Apache 2.0.26 and
486 later.</compatibility>
489 <p>The <directive>AddOutputFilter</directive> directive maps the
490 filename extension <var>extension</var> to the <a
491 href="../filter.html">filters</a> which will process responses
492 from the server before they are sent to the client. This is in
493 addition to any filters defined elsewhere, including <directive
494 module="core">SetOutputFilter</directive> and <directive module="mod_filter"
495 >AddOutputFilterByType</directive> directive. This mapping is merged
496 over any already in force, overriding any mappings that already exist
497 for the same <var>extension</var>.</p>
499 <p>For example, the following configuration will process all
500 <code>.shtml</code> files for server-side includes and will then
501 compress the output using <module>mod_deflate</module>.</p>
503 <highlight language="config">
504 AddOutputFilter INCLUDES;DEFLATE shtml
507 <p>If more than one filter is specified, they must be separated
508 by semicolons in the order in which they should process the
509 content. The <var>filter</var> argument is case-insensitive.</p>
511 <p>The <var>extension</var> argument is case-insensitive and can
512 be specified with or without a leading dot. Filenames may have <a
513 href="#multipleext">multiple extensions</a> and the
514 <var>extension</var> argument will be compared against each of
517 <p>Note that when defining a set of filters using the
518 <directive module="mod_mime">AddOutputFilter</directive> directive,
519 any definition made will replace any previous definition made by
520 the <directive module="mod_mime">AddOutputFilter</directive>
523 <highlight language="config">
524 # Effective filter "DEFLATE"
525 AddOutputFilter DEFLATE shtml
526 <Location /foo>
527 # Effective filter "INCLUDES", replacing "DEFLATE"
528 AddOutputFilter INCLUDES shtml
530 <Location /bar>
531 # Effective filter "INCLUDES;DEFLATE", replacing "DEFLATE"
532 AddOutputFilter INCLUDES;DEFLATE shtml
534 <Location /bar/baz>
535 # Effective filter "BUFFER", replacing "INCLUDES;DEFLATE"
536 AddOutputFilter BUFFER shtml
538 <Location /bar/baz/buz>
539 # No effective filter, replacing "BUFFER"
540 RemoveOutputFilter shtml
544 <seealso><directive module="mod_mime">RemoveOutputFilter</directive></seealso>
545 <seealso><directive module="core">SetOutputFilter</directive></seealso>
550 <description>Maps the given filename extensions onto the specified content
552 <syntax>AddType <var>media-type</var> <var>extension</var>
553 [<var>extension</var>] ...</syntax>
554 <contextlist><context>server config</context><context>virtual host</context>
555 <context>directory</context><context>.htaccess</context></contextlist>
556 <override>FileInfo</override>
559 <p>The <directive>AddType</directive> directive maps the given
560 filename extensions onto the specified content
561 type. <var>media-type</var> is the <glossary ref="media-type">media
562 type</glossary> to use for filenames containing
563 <var>extension</var>. This mapping is added to any already in
564 force, overriding any mappings that already exist for the same
565 <var>extension</var>.</p>
568 It is recommended that new media types be added using the
569 <directive>AddType</directive> directive rather than changing the
570 <directive module="mod_mime">TypesConfig</directive> file.
573 <example><title>Example</title>
574 <highlight language="config">
575 AddType image/gif .gif
579 <p>Or, to specify multiple file extensions in one directive:</p>
581 <example><title>Example</title>
582 <highlight language="config">
583 AddType image/jpeg jpeg jpg jpe
587 <p>The <var>extension</var> argument is case-insensitive and can
588 be specified with or without a leading dot. Filenames may have <a
589 href="#multipleext">multiple extensions</a> and the
590 <var>extension</var> argument will be compared against each of
593 <p>A simmilar effect to <module>mod_negotiation</module>'s
594 <directive module="mod_negotiation">LanguagePriority</directive>
595 can be achieved by qualifying a <var>media-type</var> with
598 <example><title>Example</title>
599 <highlight language="config">
600 AddType application/rss+xml;qs=0.8 .xml
604 <p>This is useful in situations, <em>e.g.</em> when a client
605 requesting <code>Accept: */*</code> can not actually processes
606 the content returned by the server.</p>
608 <p>This directive primarily configures the content types generated for
609 static files served out of the filesystem. For resources other than
610 static files, where the generator of the response typically specifies
611 a Content-Type, this directive has no effect.</p>
614 <seealso><directive module="core">ForceType</directive></seealso>
615 <seealso><module>mod_negotiation</module></seealso>
619 <name>MultiviewsMatch</name>
620 <description>The types of files that will be included when searching for
621 a matching file with MultiViews</description>
622 <syntax>MultiviewsMatch Any|NegotiatedOnly|Filters|Handlers
623 [Handlers|Filters]</syntax>
624 <default>MultiviewsMatch NegotiatedOnly</default>
625 <contextlist><context>server config</context><context>virtual host</context>
626 <context>directory</context><context>.htaccess</context></contextlist>
627 <override>FileInfo</override>
628 <compatibility>Available in Apache 2.0.26 and later.</compatibility>
631 <p><directive>MultiviewsMatch</directive> permits three different
632 behaviors for <a href="mod_negotiation.html">mod_negotiation</a>'s
633 Multiviews feature. Multiviews allows a request for a file,
634 <em>e.g.</em> <code>index.html</code>, to match any negotiated
635 extensions following the base request, <em>e.g.</em>
636 <code>index.html.en</code>, <code>index.html.fr</code>, or
637 <code>index.html.gz</code>.</p>
639 <p>The <code>NegotiatedOnly</code> option provides that every extension
640 following the base name must correlate to a recognized
641 <module>mod_mime</module> extension for content negotiation, <em>e.g.</em>
642 Charset, Content-Type, Language, or Encoding. This is the strictest
643 implementation with the fewest unexpected side effects, and is the
644 default behavior.</p>
646 <p>To include extensions associated with Handlers and/or Filters,
647 set the <directive>MultiviewsMatch</directive> directive to either
648 <code>Handlers</code>, <code>Filters</code>, or both option keywords.
649 If all other factors are equal, the smallest file will be served,
650 <em>e.g.</em> in deciding between <code>index.html.cgi</code> of 500
651 bytes and <code>index.html.pl</code> of 1000 bytes, the <code>.cgi</code>
652 file would win in this example. Users of <code>.asis</code> files
653 might prefer to use the Handler option, if <code>.asis</code> files are
654 associated with the <code>asis-handler</code>.</p>
656 <p>You may finally allow <code>Any</code> extensions to match, even if
657 <module>mod_mime</module> doesn't recognize the extension. This can cause
658 unpredicatable results, such as serving .old or .bak files the webmaster
659 never expected to be served.</p>
661 <p>For example, the following configuration will allow handlers
662 and filters to participate in Multviews, but will exclude unknown
665 <highlight language="config">
666 MultiviewsMatch Handlers Filters
669 <p><directive>MultiviewsMatch</directive> is not allowed in a
670 <directive type="section" module="core">Location</directive> or <directive
671 type="section" module="core">LocationMatch</directive> section.</p>
674 <seealso><directive module="core">Options</directive></seealso>
675 <seealso><module>mod_negotiation</module></seealso>
679 <name>DefaultLanguage</name>
680 <description>Defines a default language-tag to be sent in the Content-Language
681 header field for all resources in the current context that have not been
682 assigned a language-tag by some other means.</description>
683 <syntax>DefaultLanguage <var>language-tag</var></syntax>
684 <contextlist><context>server config</context><context>virtual host</context>
685 <context>directory</context><context>.htaccess</context></contextlist>
686 <override>FileInfo</override>
689 <p>The <directive>DefaultLanguage</directive> directive tells Apache
690 that all resources in the directive's scope (<em>e.g.</em>, all resources
691 covered by the current <directive module="core" type="section"
692 >Directory</directive> container) that don't have an explicit language
693 extension (such as <code>.fr</code> or <code>.de</code> as configured
694 by <directive module="mod_mime">AddLanguage</directive>) should be
695 assigned a Content-Language of <var>language-tag</var>. This allows
696 entire directory trees to be marked as containing Dutch content, for
697 instance, without having to rename each file. Note that unlike using
698 extensions to specify languages, <directive>DefaultLanguage</directive>
699 can only specify a single language.</p>
701 <p>If no <directive>DefaultLanguage</directive> directive is in force
702 and a file does not have any language extensions as configured
703 by <directive module="mod_mime">AddLanguage</directive>, then no
704 Content-Language header field will be generated.</p>
706 <example><title>Example</title>
707 <highlight language="config">
712 <seealso><module>mod_negotiation</module></seealso>
716 <name>ModMimeUsePathInfo</name>
717 <description>Tells <module>mod_mime</module> to treat <code>path_info</code>
718 components as part of the filename</description>
719 <syntax>ModMimeUsePathInfo On|Off</syntax>
720 <default>ModMimeUsePathInfo Off</default>
721 <contextlist><context>directory</context></contextlist>
722 <compatibility>Available in Apache 2.0.41 and later</compatibility>
725 <p>The <directive>ModMimeUsePathInfo</directive> directive is used to
726 combine the filename with the <code>path_info</code> URL component to
727 apply <module>mod_mime</module>'s directives to the request. The default
728 value is <code>Off</code> - therefore, the <code>path_info</code>
729 component is ignored.</p>
731 <p>This directive is recommended when you have a virtual filesystem.</p>
733 <example><title>Example</title>
734 <highlight language="config">
735 ModMimeUsePathInfo On
739 <p>If you have a request for <code>/index.php/foo.shtml</code>
740 <module>mod_mime</module> will now treat the
741 incoming request as <code>/index.php/foo.shtml</code> and directives
742 like <code>AddOutputFilter INCLUDES .shtml</code> will add the
743 <code>INCLUDES</code> filter to the request. If <directive
744 >ModMimeUsePathInfo</directive> is not set, the
745 <code>INCLUDES</code> filter will not be added. This will work
746 analogously for virtual paths, such as those defined by
747 <directive type="section">Location</directive></p>
749 <seealso><directive module="core">AcceptPathInfo</directive></seealso>
753 <name>RemoveCharset</name>
754 <description>Removes any character set associations for a set of file
755 extensions</description>
756 <syntax>RemoveCharset <var>extension</var> [<var>extension</var>]
758 <contextlist><context>virtual host</context><context>directory</context>
759 <context>.htaccess</context></contextlist>
760 <override>FileInfo</override>
761 <compatibility>RemoveCharset is only available in Apache 2.0.24 and
762 later.</compatibility>
765 <p>The <directive>RemoveCharset</directive> directive removes any
766 character set associations for files with the given extensions.
767 This allows <code>.htaccess</code> files in subdirectories to
768 undo any associations inherited from parent directories or the
769 server config files.</p>
771 <p>The <var>extension</var> argument is case-insensitive and can
772 be specified with or without a leading dot.</p>
774 <example><title>Example</title>
775 <highlight language="config">
776 RemoveCharset .html .shtml
783 <name>RemoveEncoding</name>
784 <description>Removes any content encoding associations for a set of file
785 extensions</description>
786 <syntax>RemoveEncoding <var>extension</var> [<var>extension</var>]
788 <contextlist><context>virtual host</context><context>directory</context>
789 <context>.htaccess</context></contextlist>
790 <override>FileInfo</override>
793 <p>The <directive>RemoveEncoding</directive> directive removes any
794 encoding associations for files with the given extensions. This
795 allows <code>.htaccess</code> files in subdirectories to undo
796 any associations inherited from parent directories or the
797 server config files. An example of its use might be:</p>
799 <example><title>/foo/.htaccess:</title>
800 <highlight language="config">
801 AddEncoding x-gzip .gz
802 AddType text/plain .asc
803 <Files *.gz.asc>
809 <p>This will cause <code>foo.gz</code> to be marked as being
810 encoded with the gzip method, but <code>foo.gz.asc</code> as an
811 unencoded plaintext file.</p>
813 <note><title>Note</title>
814 <p><directive>RemoveEncoding</directive> directives are processed
815 <em>after</em> any <directive module="mod_mime">AddEncoding</directive>
816 directives, so it is possible they may undo the effects of the latter
817 if both occur within the same directory configuration.</p>
820 <p>The <var>extension</var> argument is case-insensitive and can
821 be specified with or without a leading dot.</p>
826 <name>RemoveHandler</name>
827 <description>Removes any handler associations for a set of file
828 extensions</description>
829 <syntax>RemoveHandler <var>extension</var> [<var>extension</var>]
831 <contextlist><context>virtual host</context><context>directory</context>
832 <context>.htaccess</context></contextlist>
833 <override>FileInfo</override>
836 <p>The <directive>RemoveHandler</directive> directive removes any
837 handler associations for files with the given extensions. This allows
838 <code>.htaccess</code> files in subdirectories to undo any
839 associations inherited from parent directories or the server
840 config files. An example of its use might be:</p>
842 <example><title>/foo/.htaccess:</title>
843 <highlight language="config">
844 AddHandler server-parsed .html
848 <example><title>/foo/bar/.htaccess:</title>
849 <highlight language="config">
854 <p>This has the effect of returning <code>.html</code> files in
855 the <code>/foo/bar</code> directory to being treated as normal
856 files, rather than as candidates for parsing (see the <module
857 >mod_include</module> module).</p>
859 <p>The <var>extension</var> argument is case-insensitive and can
860 be specified with or without a leading dot.</p>
865 <name>RemoveInputFilter</name>
866 <description>Removes any input filter associations for a set of file
867 extensions</description>
868 <syntax>RemoveInputFilter <var>extension</var> [<var>extension</var>]
870 <contextlist><context>virtual host</context><context>directory</context>
871 <context>.htaccess</context></contextlist>
872 <override>FileInfo</override>
873 <compatibility>RemoveInputFilter is only available in Apache 2.0.26 and
874 later.</compatibility>
877 <p>The <directive>RemoveInputFilter</directive> directive removes any
878 input <a href="../filter.html">filter</a> associations for files with
879 the given extensions.
880 This allows <code>.htaccess</code> files in subdirectories to
881 undo any associations inherited from parent directories or the
882 server config files.</p>
884 <p>The <var>extension</var> argument is case-insensitive and can
885 be specified with or without a leading dot.</p>
887 <seealso><directive module="mod_mime">AddInputFilter</directive></seealso>
888 <seealso><directive module="core">SetInputFilter</directive></seealso>
892 <name>RemoveLanguage</name>
893 <description>Removes any language associations for a set of file
894 extensions</description>
895 <syntax>RemoveLanguage <var>extension</var> [<var>extension</var>]
897 <contextlist><context>virtual host</context><context>directory</context>
898 <context>.htaccess</context></contextlist>
899 <override>FileInfo</override>
900 <compatibility>RemoveLanguage is only available in Apache 2.0.24 and
901 later.</compatibility>
904 <p>The <directive>RemoveLanguage</directive> directive removes any
905 language associations for files with the given extensions. This
906 allows <code>.htaccess</code> files in subdirectories to undo
907 any associations inherited from parent directories or the
908 server config files.</p>
910 <p>The <var>extension</var> argument is case-insensitive and can
911 be specified with or without a leading dot.</p>
916 <name>RemoveOutputFilter</name>
917 <description>Removes any output filter associations for a set of file
918 extensions</description>
919 <syntax>RemoveOutputFilter <var>extension</var> [<var>extension</var>]
921 <contextlist><context>virtual host</context><context>directory</context>
922 <context>.htaccess</context></contextlist>
923 <override>FileInfo</override>
924 <compatibility>RemoveOutputFilter is only available in Apache 2.0.26 and
925 later.</compatibility>
928 <p>The <directive>RemoveOutputFilter</directive> directive removes any
929 output <a href="../filter.html">filter</a> associations for files with
930 the given extensions.
931 This allows <code>.htaccess</code> files in subdirectories to
932 undo any associations inherited from parent directories or the
933 server config files.</p>
935 <p>The <var>extension</var> argument is case-insensitive and can
936 be specified with or without a leading dot.</p>
938 <example><title>Example</title>
939 <highlight language="config">
940 RemoveOutputFilter shtml
944 <seealso><directive module="mod_mime">AddOutputFilter</directive></seealso>
948 <name>RemoveType</name>
949 <description>Removes any content type associations for a set of file
950 extensions</description>
951 <syntax>RemoveType <var>extension</var> [<var>extension</var>]
953 <contextlist><context>virtual host</context><context>directory</context>
954 <context>.htaccess</context></contextlist>
955 <override>FileInfo</override>
958 <p>The <directive>RemoveType</directive> directive removes any
959 <glossary ref="media-type">media type</glossary> associations for files with
960 the given extensions. This allows <code>.htaccess</code> files in
961 subdirectories to undo any associations inherited from parent
962 directories or the server config files. An example of its use
965 <example><title>/foo/.htaccess:</title>
966 <highlight language="config">
971 <p>This will remove any special handling of <code>.cgi</code>
972 files in the <code>/foo/</code> directory and any beneath it,
973 causing responses containing those files to omit the HTTP
974 Content-Type header field.</p>
976 <note><title>Note</title>
977 <p><directive>RemoveType</directive> directives are processed
978 <em>after</em> any <directive module="mod_mime">AddType</directive>
979 directives, so it is possible they may undo the effects of the
980 latter if both occur within the same directory configuration.</p>
983 <p>The <var>extension</var> argument is case-insensitive and can
984 be specified with or without a leading dot.</p>
989 <name>TypesConfig</name>
990 <description>The location of the <code>mime.types</code> file</description>
991 <syntax>TypesConfig <var>file-path</var></syntax>
992 <default>TypesConfig conf/mime.types</default>
993 <contextlist><context>server config</context></contextlist>
996 <p>The <directive>TypesConfig</directive> directive sets the
997 location of the <glossary ref="media-type">media types</glossary>
998 configuration file. <var>File-path</var> is relative to the
999 <directive module="core">ServerRoot</directive>. This file sets
1000 the default list of mappings from filename extensions to content
1001 types. Most administrators use the <code>mime.types</code> file
1002 provided by their OS, which associates common filename
1003 extensions with the official list of IANA registered media types
1004 maintained at <a href=
1005 "http://www.iana.org/assignments/media-types/index.html"
1006 >http://www.iana.org/assignments/media-types/index.html</a>
1007 as well as a large number of unofficial types. This
1008 simplifies the <code>httpd.conf</code> file by providing the
1009 majority of media-type definitions, and may be overridden by
1010 <directive module="mod_mime">AddType</directive> directives as
1011 needed. You should not edit the <code>mime.types</code> file,
1012 because it may be replaced when you upgrade your server.</p>
1014 <p>The file contains lines in the format of the arguments to
1015 an <directive module="mod_mime">AddType</directive> directive:</p>
1018 <var>media-type</var> [<var>extension</var>] ...
1021 <p>The case of the extension does not matter. Blank lines, and lines
1022 beginning with a hash character (<code>#</code>) are ignored.
1023 Empty lines are there for completeness (of the mime.types file).
1024 Apache httpd can still determine these types with <module
1025 >mod_mime_magic</module>.
1029 Please do <strong>not</strong> send requests to the Apache HTTP
1030 Server Project to add any new entries in the distributed
1031 <code>mime.types</code> file unless (1) they are already
1032 registered with IANA, and (2) they use widely accepted,
1033 non-conflicting filename extensions across platforms.
1034 <code>category/x-subtype</code> requests will be automatically
1035 rejected, as will any new two-letter extensions as they will
1036 likely conflict later with the already crowded language and
1037 character set namespace.
1040 <seealso><module>mod_mime_magic</module></seealso>
1041 </directivesynopsis>