mirror of
https://github.com/apache/httpd.git
synced 2025-08-10 02:56:11 +00:00

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1678567 13f79535-47bb-0310-9956-ffa450edef68
1053 lines
45 KiB
XML
1053 lines
45 KiB
XML
<?xml version="1.0"?>
|
|
<!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
|
|
<?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
|
|
<!-- $LastChangedRevision$ -->
|
|
|
|
<!--
|
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
|
contributor license agreements. See the NOTICE file distributed with
|
|
this work for additional information regarding copyright ownership.
|
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
|
(the "License"); you may not use this file except in compliance with
|
|
the License. You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
-->
|
|
|
|
<modulesynopsis metafile="mod_mime.xml.meta">
|
|
|
|
<name>mod_mime</name>
|
|
<description>Associates the requested filename's extensions
|
|
with the file's behavior (handlers and filters)
|
|
and content (mime-type, language, character set and
|
|
encoding)</description>
|
|
<status>Base</status>
|
|
<sourcefile>mod_mime.c</sourcefile>
|
|
<identifier>mime_module</identifier>
|
|
|
|
<summary>
|
|
<p>This module is used to assign content metadata to the content
|
|
selected for an HTTP response by mapping patterns in the
|
|
URI or filenames to the metadata values. For example, the filename
|
|
extensions of content files often define the content's Internet
|
|
media type, language, character set, and content-encoding. This
|
|
information is sent in HTTP messages containing that content and
|
|
used in content negotiation when selecting alternatives, such that
|
|
the user's preferences are respected when choosing one of several
|
|
possible contents to serve. See
|
|
<module>mod_negotiation</module> for more information
|
|
about <a href="../content-negotiation.html">content negotiation</a>.</p>
|
|
|
|
<p>The directives <directive
|
|
module="mod_mime">AddCharset</directive>, <directive
|
|
module="mod_mime">AddEncoding</directive>, <directive
|
|
module="mod_mime">AddLanguage</directive> and <directive
|
|
module="mod_mime">AddType</directive> are all used to map file
|
|
extensions onto the metadata for that file. Respectively
|
|
they set the character set, content-encoding, content-language,
|
|
and <glossary>media-type</glossary> (content-type) of documents. The directive <directive
|
|
module="mod_mime">TypesConfig</directive> is used to specify a
|
|
file which also maps extensions onto media types. </p>
|
|
|
|
<p>In addition, <module>mod_mime</module> may define the <a
|
|
href="../handler.html">handler</a> and <a
|
|
href="../filter.html">filters</a> that originate and process
|
|
content. The directives <directive
|
|
module="mod_mime">AddHandler</directive>, <directive
|
|
module="mod_mime">AddOutputFilter</directive>, and <directive
|
|
module="mod_mime">AddInputFilter</directive> control the modules
|
|
or scripts that serve the document. The <directive
|
|
module="mod_mime">MultiviewsMatch</directive> directive allows
|
|
<module>mod_negotiation</module> to consider these file extensions
|
|
to be included when testing Multiviews matches.</p>
|
|
|
|
<p>While <module>mod_mime</module> associates metadata
|
|
with filename extensions, the <module>core</module> server
|
|
provides directives that are used to associate all the files in a
|
|
given container (<em>e.g.</em>, <directive type="section"
|
|
module="core">Location</directive>, <directive type="section"
|
|
module="core">Directory</directive>, or <directive type="section"
|
|
module="core">Files</directive>) with particular
|
|
metadata. These directives include <directive
|
|
module="core">ForceType</directive>, <directive
|
|
module="core">SetHandler</directive>, <directive
|
|
module="core">SetInputFilter</directive>, and <directive
|
|
module="core">SetOutputFilter</directive>. The core directives
|
|
override any filename extension mappings defined in
|
|
<module>mod_mime</module>.</p>
|
|
|
|
<p>Note that changing the metadata for a file does not
|
|
change the value of the <code>Last-Modified</code> header.
|
|
Thus, previously cached copies may still be used by a client or
|
|
proxy, with the previous headers. If you change the
|
|
metadata (language, content type, character set or
|
|
encoding) you may need to 'touch' affected files (updating
|
|
their last modified date) to ensure that all visitors are
|
|
receive the corrected content headers.</p>
|
|
</summary>
|
|
<seealso><directive
|
|
module="mod_mime_magic">MimeMagicFile</directive></seealso>
|
|
<seealso><directive module="core">AddDefaultCharset</directive></seealso>
|
|
<seealso><directive module="core">ForceType</directive></seealso>
|
|
<seealso><directive module="core">SetHandler</directive></seealso>
|
|
<seealso><directive module="core">SetInputFilter</directive></seealso>
|
|
<seealso><directive module="core">SetOutputFilter</directive></seealso>
|
|
|
|
<section id="multipleext"><title>Files with Multiple Extensions</title>
|
|
<p>Files can have more than one extension; the order of the
|
|
extensions is <em>normally</em> irrelevant. For example, if the
|
|
file <code>welcome.html.fr</code> maps onto content type
|
|
<code>text/html</code> and language French then the file
|
|
<code>welcome.fr.html</code> will map onto exactly the same
|
|
information. If more than one extension is given that maps onto
|
|
the same type of metadata, then the one to the right will
|
|
be used, except for languages and content encodings. For example,
|
|
if <code>.gif</code> maps to the <glossary>media-type</glossary>
|
|
<code>image/gif</code> and <code>.html</code> maps to the
|
|
media-type <code>text/html</code>, then the file
|
|
<code>welcome.gif.html</code> will be associated with the
|
|
media-type <code>text/html</code>.</p>
|
|
|
|
<p><a href="#charset-lang">Languages</a> and <a href="#contentencoding"
|
|
>content encodings</a> are treated accumulative, because one can assign
|
|
more than one language or encoding to a particular resource. For example,
|
|
the file <code>welcome.html.en.de</code> will be delivered with
|
|
<code>Content-Language: en, de</code> and <code>Content-Type:
|
|
text/html</code>.</p>
|
|
|
|
<p>Care should be taken when a file with multiple extensions
|
|
gets associated with both a <glossary>media-type</glossary>
|
|
and a handler. This will
|
|
usually result in the request being handled by the module associated
|
|
with the handler. For example, if the <code>.imap</code>
|
|
extension is mapped to the handler <code>imap-file</code> (from
|
|
<module>mod_imagemap</module>) and the <code>.html</code> extension is
|
|
mapped to the media-type <code>text/html</code>, then the file
|
|
<code>world.imap.html</code> will be associated with both the
|
|
<code>imap-file</code> handler and <code>text/html</code> media-type.
|
|
When it is processed, the <code>imap-file</code> handler will be used,
|
|
and so it will be treated as a <module>mod_imagemap</module> imagemap
|
|
file.</p>
|
|
|
|
<p>If you would prefer only the last dot-separated part of the
|
|
filename to be mapped to a particular piece of meta-data, then do
|
|
not use the <code>Add*</code> directives. For example, if you wish
|
|
to have the file <code>foo.html.cgi</code> processed as a CGI
|
|
script, but not the file <code>bar.cgi.html</code>, then instead
|
|
of using <code>AddHandler cgi-script .cgi</code>, use</p>
|
|
|
|
<example><title>Configure handler based on final extension only</title>
|
|
<highlight language="config">
|
|
<FilesMatch "[^.]+\.cgi$">
|
|
SetHandler cgi-script
|
|
</FilesMatch>
|
|
</highlight>
|
|
</example>
|
|
|
|
</section>
|
|
|
|
<section id="contentencoding"><title>Content encoding</title>
|
|
<p>A file of a particular <glossary>media-type</glossary> can additionally be encoded a
|
|
particular way to simplify transmission over the Internet.
|
|
While this usually will refer to compression, such as
|
|
<code>gzip</code>, it can also refer to encryption, such a
|
|
<code>pgp</code> or to an encoding such as UUencoding, which is
|
|
designed for transmitting a binary file in an ASCII (text)
|
|
format.</p>
|
|
|
|
<p>The <a href="http://www.ietf.org/rfc/rfc2616.txt">HTTP/1.1
|
|
RFC</a>, section 14.11 puts it this way:</p>
|
|
|
|
<blockquote cite="http://www.ietf.org/rfc/rfc2616.txt">
|
|
<p>The Content-Encoding entity-header field is used as a modifier to
|
|
the media-type. When present, its value indicates what additional
|
|
content codings have been applied to the entity-body, and thus what
|
|
decoding mechanisms must be applied in order to obtain the media-type
|
|
referenced by the Content-Type header field. Content-Encoding is
|
|
primarily used to allow a document to be compressed without losing
|
|
the identity of its underlying media type.</p>
|
|
</blockquote>
|
|
|
|
<p>By using more than one file extension (see <a
|
|
href="#multipleext">section above about multiple file
|
|
extensions</a>), you can indicate that a file is of a
|
|
particular <em>type</em>, and also has a particular
|
|
<em>encoding</em>. </p>
|
|
|
|
<p>For example, you may have a file which is a Microsoft Word
|
|
document, which is pkzipped to reduce its size. If the
|
|
<code>.doc</code> extension is associated with the Microsoft
|
|
Word file type, and the <code>.zip</code> extension is
|
|
associated with the pkzip file encoding, then the file
|
|
<code>Resume.doc.zip</code> would be known to be a pkzip'ed Word
|
|
document.</p>
|
|
|
|
<p>Apache sends a <code>Content-encoding</code> header with the
|
|
resource, in order to tell the client browser about the
|
|
encoding method.</p>
|
|
|
|
<highlight language="config">Content-encoding: pkzip</highlight>
|
|
</section>
|
|
|
|
<section id="charset-lang"><title>Character sets and languages</title>
|
|
<p>In addition to file type and the file encoding,
|
|
another important piece of information is what language a
|
|
particular document is in, and in what character set the file
|
|
should be displayed. For example, the document might be written
|
|
in the Vietnamese alphabet, or in Cyrillic, and should be
|
|
displayed as such. This information, also, is transmitted in
|
|
HTTP headers.</p>
|
|
|
|
<p>The character set, language, encoding and mime type are all
|
|
used in the process of content negotiation (See
|
|
<module>mod_negotiation</module>) to determine
|
|
which document to give to the client, when there are
|
|
alternative documents in more than one character set, language,
|
|
encoding or mime type. All filename extensions associations
|
|
created with <directive module="mod_mime">AddCharset</directive>,
|
|
<directive module="mod_mime">AddEncoding</directive>, <directive
|
|
module="mod_mime">AddLanguage</directive> and <directive
|
|
module="mod_mime">AddType</directive> directives
|
|
(and extensions listed in the <directive module="mod_mime_magic"
|
|
>MimeMagicFile</directive>) participate in this select process.
|
|
Filename extensions that are only associated using the <directive
|
|
module="mod_mime">AddHandler</directive>, <directive module="mod_mime"
|
|
>AddInputFilter</directive> or <directive module="mod_mime"
|
|
>AddOutputFilter</directive> directives may be included or excluded
|
|
from matching by using the <directive module="mod_mime"
|
|
>MultiviewsMatch</directive> directive.</p>
|
|
|
|
<section id="charset"><title>Charset</title>
|
|
<p>To convey this further information, Apache optionally sends
|
|
a <code>Content-Language</code> header, to specify the language
|
|
that the document is in, and can append additional information
|
|
onto the <code>Content-Type</code> header to indicate the
|
|
particular character set that should be used to correctly
|
|
render the information.</p>
|
|
|
|
<example>
|
|
Content-Language: en, fr
|
|
Content-Type: text/plain; charset=ISO-8859-1
|
|
</example>
|
|
|
|
<p>The language specification is the two-letter abbreviation
|
|
for the language. The <code>charset</code> is the name of the
|
|
particular character set which should be used.</p>
|
|
</section>
|
|
</section>
|
|
|
|
<directivesynopsis>
|
|
<name>AddCharset</name>
|
|
<description>Maps the given filename extensions to the specified content
|
|
charset</description>
|
|
<syntax>AddCharset <var>charset</var> <var>extension</var>
|
|
[<var>extension</var>] ...</syntax>
|
|
<contextlist><context>server config</context><context>virtual host</context>
|
|
<context>directory</context><context>.htaccess</context></contextlist>
|
|
<override>FileInfo</override>
|
|
|
|
<usage>
|
|
<p>The <directive>AddCharset</directive> directive maps the given
|
|
filename extensions to the specified content charset (the Internet
|
|
registered name for a given character encoding). <var>charset</var>
|
|
is the <a href="http://www.iana.org/assignments/character-sets">media
|
|
type's charset parameter</a> for resources with filenames containing
|
|
<var>extension</var>. This mapping is added to any already in force,
|
|
overriding any mappings that already exist for the same
|
|
<var>extension</var>.</p>
|
|
|
|
<example><title>Example</title>
|
|
<highlight language="config">
|
|
AddLanguage ja .ja
|
|
AddCharset EUC-JP .euc
|
|
AddCharset ISO-2022-JP .jis
|
|
AddCharset SHIFT_JIS .sjis
|
|
</highlight>
|
|
</example>
|
|
|
|
<p>Then the document <code>xxxx.ja.jis</code> will be treated
|
|
as being a Japanese document whose charset is <code>ISO-2022-JP</code>
|
|
(as will the document <code>xxxx.jis.ja</code>). The
|
|
<directive>AddCharset</directive> directive is useful for both to
|
|
inform the client about the character encoding of the document so that
|
|
the document can be interpreted and displayed appropriately, and for <a
|
|
href="../content-negotiation.html">content negotiation</a>,
|
|
where the server returns one from several documents based on
|
|
the client's charset preference.</p>
|
|
|
|
<p>The <var>extension</var> argument is case-insensitive and can
|
|
be specified with or without a leading dot. Filenames may have <a
|
|
href="#multipleext">multiple extensions</a> and the
|
|
<var>extension</var> argument will be compared against each of
|
|
them.</p>
|
|
|
|
</usage>
|
|
<seealso><module>mod_negotiation</module></seealso>
|
|
<seealso><directive module="core">AddDefaultCharset</directive></seealso>
|
|
</directivesynopsis>
|
|
|
|
<directivesynopsis>
|
|
<name>AddEncoding</name>
|
|
<description>Maps the given filename extensions to the specified encoding
|
|
type</description>
|
|
<syntax>AddEncoding <var>encoding</var> <var>extension</var>
|
|
[<var>extension</var>] ...</syntax>
|
|
<contextlist><context>server config</context><context>virtual host</context>
|
|
<context>directory</context><context>.htaccess</context></contextlist>
|
|
<override>FileInfo</override>
|
|
|
|
<usage>
|
|
<p>The <directive>AddEncoding</directive> directive maps the given
|
|
filename extensions to the specified HTTP content-encoding.
|
|
<var>encoding</var> is the HTTP content coding to append to the
|
|
value of the Content-Encoding header field for documents named with the
|
|
<var>extension</var>. This mapping is added to any already in force,
|
|
overriding any mappings that already exist for the same
|
|
<var>extension</var>.</p>
|
|
|
|
<example><title>Example</title>
|
|
<highlight language="config">
|
|
AddEncoding x-gzip .gz
|
|
AddEncoding x-compress .Z
|
|
</highlight>
|
|
</example>
|
|
|
|
<p>This will cause filenames containing the <code>.gz</code> extension
|
|
to be marked as encoded using the <code>x-gzip</code> encoding, and
|
|
filenames containing the <code>.Z</code> extension to be marked as
|
|
encoded with <code>x-compress</code>.</p>
|
|
|
|
<p>Old clients expect <code>x-gzip</code> and <code>x-compress</code>,
|
|
however the standard dictates that they're equivalent to
|
|
<code>gzip</code> and <code>compress</code> respectively. Apache does
|
|
content encoding comparisons by ignoring any leading <code>x-</code>.
|
|
When responding with an encoding Apache will use whatever form
|
|
(<em>i.e.</em>, <code>x-foo</code> or <code>foo</code>) the
|
|
client requested. If the client didn't specifically request a
|
|
particular form Apache will use the form given by the
|
|
<code>AddEncoding</code> directive. To make this long story
|
|
short, you should always use <code>x-gzip</code> and
|
|
<code>x-compress</code> for these two specific encodings. More
|
|
recent encodings, such as <code>deflate</code>, should be
|
|
specified without the <code>x-</code>.</p>
|
|
|
|
<p>The <var>extension</var> argument is case-insensitive and can
|
|
be specified with or without a leading dot. Filenames may have <a
|
|
href="#multipleext">multiple extensions</a> and the
|
|
<var>extension</var> argument will be compared against each of
|
|
them.</p>
|
|
</usage>
|
|
</directivesynopsis>
|
|
|
|
<directivesynopsis>
|
|
<name>AddHandler</name>
|
|
<description>Maps the filename extensions to the specified
|
|
handler</description>
|
|
<syntax>AddHandler <var>handler-name</var> <var>extension</var>
|
|
[<var>extension</var>] ...</syntax>
|
|
<contextlist><context>server config</context><context>virtual host</context>
|
|
<context>directory</context><context>.htaccess</context></contextlist>
|
|
<override>FileInfo</override>
|
|
|
|
<usage>
|
|
<p>Files having the name <var>extension</var> will be served by the
|
|
specified <var><a href="../handler.html">handler-name</a></var>. This
|
|
mapping is added to any already in force, overriding any mappings that
|
|
already exist for the same <var>extension</var>. For example, to
|
|
activate CGI scripts with the file extension <code>.cgi</code>, you
|
|
might use:</p>
|
|
|
|
<highlight language="config">
|
|
AddHandler cgi-script .cgi
|
|
</highlight>
|
|
|
|
<p>Once that has been put into your httpd.conf file, any file containing
|
|
the <code>.cgi</code> extension will be treated as a CGI program.</p>
|
|
|
|
<p>The <var>extension</var> argument is case-insensitive and can
|
|
be specified with or without a leading dot. Filenames may have <a
|
|
href="#multipleext">multiple extensions</a> and the
|
|
<var>extension</var> argument will be compared against each of
|
|
them.</p>
|
|
</usage>
|
|
<seealso><directive module="core">SetHandler</directive></seealso>
|
|
</directivesynopsis>
|
|
|
|
<directivesynopsis>
|
|
<name>AddInputFilter</name>
|
|
<description>Maps filename extensions to the filters that will process
|
|
client requests</description>
|
|
<syntax>AddInputFilter <var>filter</var>[;<var>filter</var>...]
|
|
<var>extension</var> [<var>extension</var>] ...</syntax>
|
|
<contextlist><context>server config</context><context>virtual host</context>
|
|
<context>directory</context><context>.htaccess</context></contextlist>
|
|
<override>FileInfo</override>
|
|
|
|
<usage>
|
|
<p><directive>AddInputFilter</directive> maps the filename extension
|
|
<var>extension</var> to the <a href="../filter.html">filters</a> which
|
|
will process client requests and POST input when they are received by
|
|
the server. This is in addition to any filters defined elsewhere,
|
|
including the <directive module="core">SetInputFilter</directive>
|
|
directive. This mapping is merged over any already in force, overriding
|
|
any mappings that already exist for the same <var>extension</var>.</p>
|
|
|
|
<p>If more than one <var>filter</var> is specified, they must be separated
|
|
by semicolons in the order in which they should process the
|
|
content. The <var>filter</var> is case-insensitive.</p>
|
|
|
|
<p>The <var>extension</var> argument is case-insensitive and can
|
|
be specified with or without a leading dot. Filenames may have <a
|
|
href="#multipleext">multiple extensions</a> and the
|
|
<var>extension</var> argument will be compared against each of
|
|
them.</p>
|
|
|
|
</usage>
|
|
<seealso><directive module="mod_mime">RemoveInputFilter</directive></seealso>
|
|
<seealso><directive module="core">SetInputFilter</directive></seealso>
|
|
</directivesynopsis>
|
|
|
|
<directivesynopsis>
|
|
<name>AddLanguage</name>
|
|
<description>Maps the given filename extension to the specified content
|
|
language</description>
|
|
<syntax>AddLanguage <var>language-tag</var> <var>extension</var>
|
|
[<var>extension</var>] ...</syntax>
|
|
<contextlist><context>server config</context><context>virtual host</context>
|
|
<context>directory</context><context>.htaccess</context></contextlist>
|
|
<override>FileInfo</override>
|
|
|
|
<usage>
|
|
<p>The <directive>AddLanguage</directive> directive maps the given
|
|
filename extension to the specified content language. Files with the
|
|
filename <var>extension</var> are assigned an HTTP Content-Language
|
|
value of <var>language-tag</var> corresponding to the language
|
|
identifiers defined by RFC 3066.
|
|
This directive overrides any mappings that already exist for the same
|
|
<var>extension</var>.</p>
|
|
|
|
<example><title>Example</title>
|
|
<highlight language="config">
|
|
AddEncoding x-compress .Z
|
|
AddLanguage en .en
|
|
AddLanguage fr .fr
|
|
</highlight>
|
|
</example>
|
|
|
|
<p>Then the document <code>xxxx.en.Z</code> will be treated as
|
|
being a compressed English document (as will the document
|
|
<code>xxxx.Z.en</code>). Although the content language is
|
|
reported to the client, the browser is unlikely to use this
|
|
information. The <directive>AddLanguage</directive> directive is
|
|
more useful for <a href="../content-negotiation.html">content
|
|
negotiation</a>, where the server returns one from several documents
|
|
based on the client's language preference.</p>
|
|
|
|
<p>If multiple language assignments are made for the same
|
|
extension, the last one encountered is the one that is used.
|
|
That is, for the case of:</p>
|
|
|
|
<highlight language="config">
|
|
AddLanguage en .en
|
|
AddLanguage en-gb .en
|
|
AddLanguage en-us .en
|
|
</highlight>
|
|
|
|
<p>documents with the extension <code>.en</code> would be treated as
|
|
being <code>en-us</code>.</p>
|
|
|
|
<p>The <var>extension</var> argument is case-insensitive and can
|
|
be specified with or without a leading dot. Filenames may have <a
|
|
href="#multipleext">multiple extensions</a> and the
|
|
<var>extension</var> argument will be compared against each of
|
|
them.</p>
|
|
</usage>
|
|
<seealso><module>mod_negotiation</module></seealso>
|
|
</directivesynopsis>
|
|
|
|
<directivesynopsis>
|
|
<name>AddOutputFilter</name>
|
|
<description>Maps filename extensions to the filters that will process
|
|
responses from the server</description>
|
|
<syntax>AddOutputFilter <var>filter</var>[;<var>filter</var>...]
|
|
<var>extension</var> [<var>extension</var>] ...</syntax>
|
|
<contextlist><context>server config</context><context>virtual host</context>
|
|
<context>directory</context><context>.htaccess</context></contextlist>
|
|
<override>FileInfo</override>
|
|
|
|
<usage>
|
|
<p>The <directive>AddOutputFilter</directive> directive maps the
|
|
filename extension <var>extension</var> to the <a
|
|
href="../filter.html">filters</a> which will process responses
|
|
from the server before they are sent to the client. This is in
|
|
addition to any filters defined elsewhere, including <directive
|
|
module="core">SetOutputFilter</directive> and <directive module="mod_filter"
|
|
>AddOutputFilterByType</directive> directive. This mapping is merged
|
|
over any already in force, overriding any mappings that already exist
|
|
for the same <var>extension</var>.</p>
|
|
|
|
<p>For example, the following configuration will process all
|
|
<code>.shtml</code> files for server-side includes and will then
|
|
compress the output using <module>mod_deflate</module>.</p>
|
|
|
|
<highlight language="config">
|
|
AddOutputFilter INCLUDES;DEFLATE shtml
|
|
</highlight>
|
|
|
|
<p>If more than one filter is specified, they must be separated
|
|
by semicolons in the order in which they should process the
|
|
content. The <var>filter</var> argument is case-insensitive.</p>
|
|
|
|
<p>The <var>extension</var> argument is case-insensitive and can
|
|
be specified with or without a leading dot. Filenames may have <a
|
|
href="#multipleext">multiple extensions</a> and the
|
|
<var>extension</var> argument will be compared against each of
|
|
them.</p>
|
|
|
|
<p>Note that when defining a set of filters using the
|
|
<directive module="mod_mime">AddOutputFilter</directive> directive,
|
|
any definition made will replace any previous definition made by
|
|
the <directive module="mod_mime">AddOutputFilter</directive>
|
|
directive.</p>
|
|
|
|
<highlight language="config">
|
|
# Effective filter "DEFLATE"
|
|
AddOutputFilter DEFLATE shtml
|
|
<Location "/foo">
|
|
# Effective filter "INCLUDES", replacing "DEFLATE"
|
|
AddOutputFilter INCLUDES shtml
|
|
</Location>
|
|
<Location "/bar">
|
|
# Effective filter "INCLUDES;DEFLATE", replacing "DEFLATE"
|
|
AddOutputFilter INCLUDES;DEFLATE shtml
|
|
</Location>
|
|
<Location "/bar/baz">
|
|
# Effective filter "BUFFER", replacing "INCLUDES;DEFLATE"
|
|
AddOutputFilter BUFFER shtml
|
|
</Location>
|
|
<Location "/bar/baz/buz">
|
|
# No effective filter, replacing "BUFFER"
|
|
RemoveOutputFilter shtml
|
|
</Location>
|
|
</highlight>
|
|
</usage>
|
|
<seealso><directive module="mod_mime">RemoveOutputFilter</directive></seealso>
|
|
<seealso><directive module="core">SetOutputFilter</directive></seealso>
|
|
</directivesynopsis>
|
|
|
|
<directivesynopsis>
|
|
<name>AddType</name>
|
|
<description>Maps the given filename extensions onto the specified content
|
|
type</description>
|
|
<syntax>AddType <var>media-type</var> <var>extension</var>
|
|
[<var>extension</var>] ...</syntax>
|
|
<contextlist><context>server config</context><context>virtual host</context>
|
|
<context>directory</context><context>.htaccess</context></contextlist>
|
|
<override>FileInfo</override>
|
|
|
|
<usage>
|
|
<p>The <directive>AddType</directive> directive maps the given
|
|
filename extensions onto the specified content
|
|
type. <var>media-type</var> is the <glossary ref="media-type">media
|
|
type</glossary> to use for filenames containing
|
|
<var>extension</var>. This mapping is added to any already in
|
|
force, overriding any mappings that already exist for the same
|
|
<var>extension</var>.</p>
|
|
|
|
<note>
|
|
It is recommended that new media types be added using the
|
|
<directive>AddType</directive> directive rather than changing the
|
|
<directive module="mod_mime">TypesConfig</directive> file.
|
|
</note>
|
|
|
|
<example><title>Example</title>
|
|
<highlight language="config">
|
|
AddType image/gif .gif
|
|
</highlight>
|
|
</example>
|
|
|
|
<p>Or, to specify multiple file extensions in one directive:</p>
|
|
|
|
<example><title>Example</title>
|
|
<highlight language="config">
|
|
AddType image/jpeg jpeg jpg jpe
|
|
</highlight>
|
|
</example>
|
|
|
|
<p>The <var>extension</var> argument is case-insensitive and can
|
|
be specified with or without a leading dot. Filenames may have <a
|
|
href="#multipleext">multiple extensions</a> and the
|
|
<var>extension</var> argument will be compared against each of
|
|
them.</p>
|
|
|
|
<p>A simmilar effect to <module>mod_negotiation</module>'s
|
|
<directive module="mod_negotiation">LanguagePriority</directive>
|
|
can be achieved by qualifying a <var>media-type</var> with
|
|
<code>qs</code>:</p>
|
|
|
|
<example><title>Example</title>
|
|
<highlight language="config">
|
|
AddType application/rss+xml;qs=0.8 .xml
|
|
</highlight>
|
|
</example>
|
|
|
|
<p>This is useful in situations, <em>e.g.</em> when a client
|
|
requesting <code>Accept: */*</code> can not actually processes
|
|
the content returned by the server.</p>
|
|
|
|
<p>This directive primarily configures the content types generated for
|
|
static files served out of the filesystem. For resources other than
|
|
static files, where the generator of the response typically specifies
|
|
a Content-Type, this directive has no effect.</p>
|
|
|
|
|
|
<note><title>Note</title>
|
|
<p>If no handler is explicitly set for a request, the specified content
|
|
type will also be used as the handler name. </p>
|
|
|
|
<p>When explicit directives such as
|
|
<directive module="core" >SetHandler</directive> or
|
|
<directive module="mod_mime">AddHandler</directive> do not apply
|
|
to the current request, the internal handler name normally set by those
|
|
directives is instead set to the content type specified by this directive.
|
|
</p>
|
|
<p>
|
|
This is a historical behavior that may be used by some third-party modules
|
|
(such as mod_php) for taking responsibility for the matching request.
|
|
</p>
|
|
|
|
<p>Configurations that rely on such "synthetic" types should be avoided.
|
|
Additionally, configurations that restrict access to
|
|
<directive module="core" >SetHandler</directive> or
|
|
<directive module="mod_mime">AddHandler</directive> should
|
|
restrict access to this directive as well.</p>
|
|
</note>
|
|
|
|
</usage>
|
|
<seealso><directive module="core">ForceType</directive></seealso>
|
|
<seealso><module>mod_negotiation</module></seealso>
|
|
</directivesynopsis>
|
|
|
|
<directivesynopsis>
|
|
<name>MultiviewsMatch</name>
|
|
<description>The types of files that will be included when searching for
|
|
a matching file with MultiViews</description>
|
|
<syntax>MultiviewsMatch Any|NegotiatedOnly|Filters|Handlers
|
|
[Handlers|Filters]</syntax>
|
|
<default>MultiviewsMatch NegotiatedOnly</default>
|
|
<contextlist><context>server config</context><context>virtual host</context>
|
|
<context>directory</context><context>.htaccess</context></contextlist>
|
|
<override>FileInfo</override>
|
|
|
|
<usage>
|
|
<p><directive>MultiviewsMatch</directive> permits three different
|
|
behaviors for <a href="mod_negotiation.html">mod_negotiation</a>'s
|
|
Multiviews feature. Multiviews allows a request for a file,
|
|
<em>e.g.</em> <code>index.html</code>, to match any negotiated
|
|
extensions following the base request, <em>e.g.</em>
|
|
<code>index.html.en</code>, <code>index.html.fr</code>, or
|
|
<code>index.html.gz</code>.</p>
|
|
|
|
<p>The <code>NegotiatedOnly</code> option provides that every extension
|
|
following the base name must correlate to a recognized
|
|
<module>mod_mime</module> extension for content negotiation, <em>e.g.</em>
|
|
Charset, Content-Type, Language, or Encoding. This is the strictest
|
|
implementation with the fewest unexpected side effects, and is the
|
|
default behavior.</p>
|
|
|
|
<p>To include extensions associated with Handlers and/or Filters,
|
|
set the <directive>MultiviewsMatch</directive> directive to either
|
|
<code>Handlers</code>, <code>Filters</code>, or both option keywords.
|
|
If all other factors are equal, the smallest file will be served,
|
|
<em>e.g.</em> in deciding between <code>index.html.cgi</code> of 500
|
|
bytes and <code>index.html.pl</code> of 1000 bytes, the <code>.cgi</code>
|
|
file would win in this example. Users of <code>.asis</code> files
|
|
might prefer to use the Handler option, if <code>.asis</code> files are
|
|
associated with the <code>asis-handler</code>.</p>
|
|
|
|
<p>You may finally allow <code>Any</code> extensions to match, even if
|
|
<module>mod_mime</module> doesn't recognize the extension. This can cause
|
|
unpredictable results, such as serving .old or .bak files the webmaster
|
|
never expected to be served.</p>
|
|
|
|
<p>For example, the following configuration will allow handlers
|
|
and filters to participate in Multviews, but will exclude unknown
|
|
files:</p>
|
|
|
|
<highlight language="config">
|
|
MultiviewsMatch Handlers Filters
|
|
</highlight>
|
|
|
|
<p><directive>MultiviewsMatch</directive> is not allowed in a
|
|
<directive type="section" module="core">Location</directive> or <directive
|
|
type="section" module="core">LocationMatch</directive> section.</p>
|
|
|
|
</usage>
|
|
<seealso><directive module="core">Options</directive></seealso>
|
|
<seealso><module>mod_negotiation</module></seealso>
|
|
</directivesynopsis>
|
|
|
|
<directivesynopsis>
|
|
<name>DefaultLanguage</name>
|
|
<description>Defines a default language-tag to be sent in the Content-Language
|
|
header field for all resources in the current context that have not been
|
|
assigned a language-tag by some other means.</description>
|
|
<syntax>DefaultLanguage <var>language-tag</var></syntax>
|
|
<contextlist><context>server config</context><context>virtual host</context>
|
|
<context>directory</context><context>.htaccess</context></contextlist>
|
|
<override>FileInfo</override>
|
|
|
|
<usage>
|
|
<p>The <directive>DefaultLanguage</directive> directive tells Apache
|
|
that all resources in the directive's scope (<em>e.g.</em>, all resources
|
|
covered by the current <directive module="core" type="section"
|
|
>Directory</directive> container) that don't have an explicit language
|
|
extension (such as <code>.fr</code> or <code>.de</code> as configured
|
|
by <directive module="mod_mime">AddLanguage</directive>) should be
|
|
assigned a Content-Language of <var>language-tag</var>. This allows
|
|
entire directory trees to be marked as containing Dutch content, for
|
|
instance, without having to rename each file. Note that unlike using
|
|
extensions to specify languages, <directive>DefaultLanguage</directive>
|
|
can only specify a single language.</p>
|
|
|
|
<p>If no <directive>DefaultLanguage</directive> directive is in force
|
|
and a file does not have any language extensions as configured
|
|
by <directive module="mod_mime">AddLanguage</directive>, then no
|
|
Content-Language header field will be generated.</p>
|
|
|
|
<example><title>Example</title>
|
|
<highlight language="config">
|
|
DefaultLanguage en
|
|
</highlight>
|
|
</example>
|
|
</usage>
|
|
<seealso><module>mod_negotiation</module></seealso>
|
|
</directivesynopsis>
|
|
|
|
<directivesynopsis>
|
|
<name>ModMimeUsePathInfo</name>
|
|
<description>Tells <module>mod_mime</module> to treat <code>path_info</code>
|
|
components as part of the filename</description>
|
|
<syntax>ModMimeUsePathInfo On|Off</syntax>
|
|
<default>ModMimeUsePathInfo Off</default>
|
|
<contextlist><context>directory</context></contextlist>
|
|
|
|
<usage>
|
|
<p>The <directive>ModMimeUsePathInfo</directive> directive is used to
|
|
combine the filename with the <code>path_info</code> URL component to
|
|
apply <module>mod_mime</module>'s directives to the request. The default
|
|
value is <code>Off</code> - therefore, the <code>path_info</code>
|
|
component is ignored.</p>
|
|
|
|
<p>This directive is recommended when you have a virtual filesystem.</p>
|
|
|
|
<example><title>Example</title>
|
|
<highlight language="config">
|
|
ModMimeUsePathInfo On
|
|
</highlight>
|
|
</example>
|
|
|
|
<p>If you have a request for <code>/index.php/foo.shtml</code>
|
|
<module>mod_mime</module> will now treat the
|
|
incoming request as <code>/index.php/foo.shtml</code> and directives
|
|
like <code>AddOutputFilter INCLUDES .shtml</code> will add the
|
|
<code>INCLUDES</code> filter to the request. If <directive
|
|
>ModMimeUsePathInfo</directive> is not set, the
|
|
<code>INCLUDES</code> filter will not be added. This will work
|
|
analogously for virtual paths, such as those defined by
|
|
<directive type="section">Location</directive></p>
|
|
</usage>
|
|
<seealso><directive module="core">AcceptPathInfo</directive></seealso>
|
|
</directivesynopsis>
|
|
|
|
<directivesynopsis>
|
|
<name>RemoveCharset</name>
|
|
<description>Removes any character set associations for a set of file
|
|
extensions</description>
|
|
<syntax>RemoveCharset <var>extension</var> [<var>extension</var>]
|
|
...</syntax>
|
|
<contextlist><context>virtual host</context><context>directory</context>
|
|
<context>.htaccess</context></contextlist>
|
|
<override>FileInfo</override>
|
|
|
|
<usage>
|
|
<p>The <directive>RemoveCharset</directive> directive removes any
|
|
character set associations for files with the given extensions.
|
|
This allows <code>.htaccess</code> files in subdirectories to
|
|
undo any associations inherited from parent directories or the
|
|
server config files.</p>
|
|
|
|
<p>The <var>extension</var> argument is case-insensitive and can
|
|
be specified with or without a leading dot.</p>
|
|
|
|
<example><title>Example</title>
|
|
<highlight language="config">
|
|
RemoveCharset .html .shtml
|
|
</highlight>
|
|
</example>
|
|
</usage>
|
|
</directivesynopsis>
|
|
|
|
<directivesynopsis>
|
|
<name>RemoveEncoding</name>
|
|
<description>Removes any content encoding associations for a set of file
|
|
extensions</description>
|
|
<syntax>RemoveEncoding <var>extension</var> [<var>extension</var>]
|
|
...</syntax>
|
|
<contextlist><context>virtual host</context><context>directory</context>
|
|
<context>.htaccess</context></contextlist>
|
|
<override>FileInfo</override>
|
|
|
|
<usage>
|
|
<p>The <directive>RemoveEncoding</directive> directive removes any
|
|
encoding associations for files with the given extensions. This
|
|
allows <code>.htaccess</code> files in subdirectories to undo
|
|
any associations inherited from parent directories or the
|
|
server config files. An example of its use might be:</p>
|
|
|
|
<example><title>/foo/.htaccess:</title>
|
|
<highlight language="config">
|
|
AddEncoding x-gzip .gz
|
|
AddType text/plain .asc
|
|
<Files "*.gz.asc">
|
|
RemoveEncoding .gz
|
|
</Files>
|
|
</highlight>
|
|
</example>
|
|
|
|
<p>This will cause <code>foo.gz</code> to be marked as being
|
|
encoded with the gzip method, but <code>foo.gz.asc</code> as an
|
|
unencoded plaintext file.</p>
|
|
|
|
<note><title>Note</title>
|
|
<p><directive>RemoveEncoding</directive> directives are processed
|
|
<em>after</em> any <directive module="mod_mime">AddEncoding</directive>
|
|
directives, so it is possible they may undo the effects of the latter
|
|
if both occur within the same directory configuration.</p>
|
|
</note>
|
|
|
|
<p>The <var>extension</var> argument is case-insensitive and can
|
|
be specified with or without a leading dot.</p>
|
|
</usage>
|
|
</directivesynopsis>
|
|
|
|
<directivesynopsis>
|
|
<name>RemoveHandler</name>
|
|
<description>Removes any handler associations for a set of file
|
|
extensions</description>
|
|
<syntax>RemoveHandler <var>extension</var> [<var>extension</var>]
|
|
...</syntax>
|
|
<contextlist><context>virtual host</context><context>directory</context>
|
|
<context>.htaccess</context></contextlist>
|
|
<override>FileInfo</override>
|
|
|
|
<usage>
|
|
<p>The <directive>RemoveHandler</directive> directive removes any
|
|
handler associations for files with the given extensions. This allows
|
|
<code>.htaccess</code> files in subdirectories to undo any
|
|
associations inherited from parent directories or the server
|
|
config files. An example of its use might be:</p>
|
|
|
|
<example><title>/foo/.htaccess:</title>
|
|
<highlight language="config">
|
|
AddHandler server-parsed .html
|
|
</highlight>
|
|
</example>
|
|
|
|
<example><title>/foo/bar/.htaccess:</title>
|
|
<highlight language="config">
|
|
RemoveHandler .html
|
|
</highlight>
|
|
</example>
|
|
|
|
<p>This has the effect of returning <code>.html</code> files in
|
|
the <code>/foo/bar</code> directory to being treated as normal
|
|
files, rather than as candidates for parsing (see the <module
|
|
>mod_include</module> module).</p>
|
|
|
|
<p>The <var>extension</var> argument is case-insensitive and can
|
|
be specified with or without a leading dot.</p>
|
|
</usage>
|
|
</directivesynopsis>
|
|
|
|
<directivesynopsis>
|
|
<name>RemoveInputFilter</name>
|
|
<description>Removes any input filter associations for a set of file
|
|
extensions</description>
|
|
<syntax>RemoveInputFilter <var>extension</var> [<var>extension</var>]
|
|
...</syntax>
|
|
<contextlist><context>virtual host</context><context>directory</context>
|
|
<context>.htaccess</context></contextlist>
|
|
<override>FileInfo</override>
|
|
|
|
<usage>
|
|
<p>The <directive>RemoveInputFilter</directive> directive removes any
|
|
input <a href="../filter.html">filter</a> associations for files with
|
|
the given extensions.
|
|
This allows <code>.htaccess</code> files in subdirectories to
|
|
undo any associations inherited from parent directories or the
|
|
server config files.</p>
|
|
|
|
<p>The <var>extension</var> argument is case-insensitive and can
|
|
be specified with or without a leading dot.</p>
|
|
</usage>
|
|
<seealso><directive module="mod_mime">AddInputFilter</directive></seealso>
|
|
<seealso><directive module="core">SetInputFilter</directive></seealso>
|
|
</directivesynopsis>
|
|
|
|
<directivesynopsis>
|
|
<name>RemoveLanguage</name>
|
|
<description>Removes any language associations for a set of file
|
|
extensions</description>
|
|
<syntax>RemoveLanguage <var>extension</var> [<var>extension</var>]
|
|
...</syntax>
|
|
<contextlist><context>virtual host</context><context>directory</context>
|
|
<context>.htaccess</context></contextlist>
|
|
<override>FileInfo</override>
|
|
|
|
<usage>
|
|
<p>The <directive>RemoveLanguage</directive> directive removes any
|
|
language associations for files with the given extensions. This
|
|
allows <code>.htaccess</code> files in subdirectories to undo
|
|
any associations inherited from parent directories or the
|
|
server config files.</p>
|
|
|
|
<p>The <var>extension</var> argument is case-insensitive and can
|
|
be specified with or without a leading dot.</p>
|
|
</usage>
|
|
</directivesynopsis>
|
|
|
|
<directivesynopsis>
|
|
<name>RemoveOutputFilter</name>
|
|
<description>Removes any output filter associations for a set of file
|
|
extensions</description>
|
|
<syntax>RemoveOutputFilter <var>extension</var> [<var>extension</var>]
|
|
...</syntax>
|
|
<contextlist><context>virtual host</context><context>directory</context>
|
|
<context>.htaccess</context></contextlist>
|
|
<override>FileInfo</override>
|
|
|
|
<usage>
|
|
<p>The <directive>RemoveOutputFilter</directive> directive removes any
|
|
output <a href="../filter.html">filter</a> associations for files with
|
|
the given extensions.
|
|
This allows <code>.htaccess</code> files in subdirectories to
|
|
undo any associations inherited from parent directories or the
|
|
server config files.</p>
|
|
|
|
<p>The <var>extension</var> argument is case-insensitive and can
|
|
be specified with or without a leading dot.</p>
|
|
|
|
<example><title>Example</title>
|
|
<highlight language="config">
|
|
RemoveOutputFilter shtml
|
|
</highlight>
|
|
</example>
|
|
</usage>
|
|
<seealso><directive module="mod_mime">AddOutputFilter</directive></seealso>
|
|
</directivesynopsis>
|
|
|
|
<directivesynopsis>
|
|
<name>RemoveType</name>
|
|
<description>Removes any content type associations for a set of file
|
|
extensions</description>
|
|
<syntax>RemoveType <var>extension</var> [<var>extension</var>]
|
|
...</syntax>
|
|
<contextlist><context>virtual host</context><context>directory</context>
|
|
<context>.htaccess</context></contextlist>
|
|
<override>FileInfo</override>
|
|
|
|
<usage>
|
|
<p>The <directive>RemoveType</directive> directive removes any
|
|
<glossary ref="media-type">media type</glossary> associations for files with
|
|
the given extensions. This allows <code>.htaccess</code> files in
|
|
subdirectories to undo any associations inherited from parent
|
|
directories or the server config files. An example of its use
|
|
might be:</p>
|
|
|
|
<example><title>/foo/.htaccess:</title>
|
|
<highlight language="config">
|
|
RemoveType .cgi
|
|
</highlight>
|
|
</example>
|
|
|
|
<p>This will remove any special handling of <code>.cgi</code>
|
|
files in the <code>/foo/</code> directory and any beneath it,
|
|
causing responses containing those files to omit the HTTP
|
|
Content-Type header field.</p>
|
|
|
|
<note><title>Note</title>
|
|
<p><directive>RemoveType</directive> directives are processed
|
|
<em>after</em> any <directive module="mod_mime">AddType</directive>
|
|
directives, so it is possible they may undo the effects of the
|
|
latter if both occur within the same directory configuration.</p>
|
|
</note>
|
|
|
|
<p>The <var>extension</var> argument is case-insensitive and can
|
|
be specified with or without a leading dot.</p>
|
|
</usage>
|
|
</directivesynopsis>
|
|
|
|
<directivesynopsis>
|
|
<name>TypesConfig</name>
|
|
<description>The location of the <code>mime.types</code> file</description>
|
|
<syntax>TypesConfig <var>file-path</var></syntax>
|
|
<default>TypesConfig conf/mime.types</default>
|
|
<contextlist><context>server config</context></contextlist>
|
|
|
|
<usage>
|
|
<p>The <directive>TypesConfig</directive> directive sets the
|
|
location of the <glossary ref="media-type">media types</glossary>
|
|
configuration file. <var>File-path</var> is relative to the
|
|
<directive module="core">ServerRoot</directive>. This file sets
|
|
the default list of mappings from filename extensions to content
|
|
types. Most administrators use the <code>mime.types</code> file
|
|
provided by their OS, which associates common filename
|
|
extensions with the official list of IANA registered media types
|
|
maintained at <a href=
|
|
"http://www.iana.org/assignments/media-types/index.html"
|
|
>http://www.iana.org/assignments/media-types/index.html</a>
|
|
as well as a large number of unofficial types. This
|
|
simplifies the <code>httpd.conf</code> file by providing the
|
|
majority of media-type definitions, and may be overridden by
|
|
<directive module="mod_mime">AddType</directive> directives as
|
|
needed. You should not edit the <code>mime.types</code> file,
|
|
because it may be replaced when you upgrade your server.</p>
|
|
|
|
<p>The file contains lines in the format of the arguments to
|
|
an <directive module="mod_mime">AddType</directive> directive:</p>
|
|
|
|
<example>
|
|
<var>media-type</var> [<var>extension</var>] ...
|
|
</example>
|
|
|
|
<p>The case of the extension does not matter. Blank lines, and lines
|
|
beginning with a hash character (<code>#</code>) are ignored.
|
|
Empty lines are there for completeness (of the mime.types file).
|
|
Apache httpd can still determine these types with <module
|
|
>mod_mime_magic</module>.
|
|
</p>
|
|
|
|
<note>
|
|
Please do <strong>not</strong> send requests to the Apache HTTP
|
|
Server Project to add any new entries in the distributed
|
|
<code>mime.types</code> file unless (1) they are already
|
|
registered with IANA, and (2) they use widely accepted,
|
|
non-conflicting filename extensions across platforms.
|
|
<code>category/x-subtype</code> requests will be automatically
|
|
rejected, as will any new two-letter extensions as they will
|
|
likely conflict later with the already crowded language and
|
|
character set namespace.
|
|
</note>
|
|
</usage>
|
|
<seealso><module>mod_mime_magic</module></seealso>
|
|
</directivesynopsis>
|
|
|
|
</modulesynopsis>
|