1516N/A<!
DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
539N/A<
TITLE>Apache module mod_mime</
TITLE>
539N/A<!-- Background white, links blue (unvisited), navy (visited), red (active) --> 539N/A<
H1 ALIGN="CENTER">Module mod_mime</
H1>
539N/Acompiled in by default. It provides for determining the types of files
926N/AThis module is used to determine various bits of "meta information"
539N/Aabout documents. This information relates to the content of the
926N/Adocument and is returned to the browser or used in content-negotiation
539N/Awithin the server. In addition, a "handler" can be set for a document,
539N/Awhich determines how the document will be processed within the server.
732N/AThe directives <
A HREF="#addencoding">AddEncoding</
A>, <
A 539N/AHREF="#addhandler">AddHandler</
A>, <
A 539N/AHREF="#addlanguage">AddLanguage</
A> and <
A HREF="#addtype">AddType</
A>
539N/Aare all used to map file extensions onto the meta-information for that
539N/Afile. Respectively they set the content-encoding, handler,
539N/Acontent-language and mime-type (content-type) of documents. The
539N/Adirective <
A HREF="#typesconfig">TypesConfig</
A> is used to specify a
539N/Afile which also maps extensions onto mime types. The directives <
A 539N/AHREF="#forcetype">ForceType</
A> and <
A 539N/AHREF="#sethandler">SetHandler</
A> are used to associated all the files
539N/Ain a given location (
e.g. a particular directory) onto a particular
716N/AFiles can have more than one extension, and the order of the
716N/Aextensions is normally irrelevant. For example, if the file
716N/Aonto exactly the same information. The only exception to this is if an
716N/Aextension is given which Apache does not know how to handle. In this
716N/Acase it will "forget" about any information it obtained from
716N/Aextensions to the left of the unknown extension. So, for example, if
539N/Athe extensions fr and html are mapped to the appropriate language and
1431N/Atype but extension xxx is not assigned to anything, then the file
539N/ANote that changing the type or encoding of a file does not change the
539N/Avalue of the <
CODE>Last-Modified</
CODE> header. Thus, previously cached
539N/Acopies may still be used by a client or proxy, with the previous headers.
539N/APlease note that changing a file's type or encoding does not change
1431N/Athe value of the <
CODE>Last-Modified</
CODE> header. Previously cached
539N/Acopies may still be used by a client or proxy.
539N/A<
LI><
A HREF="#addencoding">AddEncoding</
A>
539N/A<
LI><
A HREF="#addhandler">AddHandler</
A>
539N/A<
LI><
A HREF="#addlanguage">AddLanguage</
A>
539N/A<
LI><
A HREF="#addtype">AddType</
A>
539N/A<
LI><
A HREF="#forcetype">ForceType</
A>
539N/A<
LI><
A HREF="#sethandler">SetHandler</
A>
539N/A<
LI><
A HREF="#typesconfig">TypesConfig</
A>
539N/A<
H2><
A name="addencoding">AddEncoding</
A></
H2>
539N/A<!--%plaintext <?INDEX {\tt AddEncoding} directive> --> 1505N/A><
STRONG>Syntax:</
STRONG></
A> AddEncoding <
EM>mime-enc extension extension...</
EM><
BR>
1505N/A><
STRONG>Context:</
STRONG></
A> server config, virtual host, directory, .htaccess<
BR>
1505N/A><
STRONG>Override:</
STRONG></
A> FileInfo<
BR>
539N/A><
STRONG>Status:</
STRONG></
A> Base<
BR>
926N/A><
STRONG>Module:</
STRONG></
A> mod_mime<
P>
926N/AThe AddEncoding directive adds to the list of filename extensions which
539N/Afilenames may end in for the specified encoding type. <
EM>Mime-enc</
EM>
539N/Ais the mime encoding to use for documents ending in <
EM>extension</
EM>.
539N/AAddEncoding x-compress Z
539N/AThis will cause files ending in .gz to be marked as encoded using the x-gzip
539N/Aencoding, and .Z files to be marked as encoded with x-compress.<
P>
539N/AOld clients expect <
code>x-gzip</
code> and <
code>x-compress</
code>,
539N/Ahowever the standard dictates that they're equivalent to <
code>gzip</
code>
539N/Aand <
code>compress</
code> respectively. Apache does content encoding
565N/Acomparisons by ignoring any leading <
code>x-</
code>. When responding
565N/Awith an encoding Apache will use whatever form (
i.e. <
code>x-foo</
code>
565N/Aor <
code>foo</
code>) the client requested. If the client didn't
539N/Aspecifically request a particular form Apache will use the form given by
539N/Athe <
code>AddEncoding</
code> directive. To make this long story short,
539N/Ayou should always use <
code>x-gzip</
code> and <
code>x-compress</
code>
539N/Afor these two specific encodings. More recent encodings, such as
1505N/A<
code>deflate</
code> should be specified without the <
code>x-</
code>.
565N/A<
H2><
A name="addhandler">AddHandler</
A></
H2>
539N/A><
STRONG>Syntax:</
STRONG></
A> AddHandler <
EM>handler-name extension extension...</
EM><
BR>
539N/A><
STRONG>Context:</
STRONG></
A> server config, virtual host, directory, .htaccess<
BR>
996N/A><
STRONG>Status:</
STRONG></
A> Base<
BR>
716N/A><
STRONG>Module:</
STRONG></
A> mod_mime<
BR>
716N/A><
STRONG>Compatibility:</
STRONG></
A> AddHandler is only available in Apache
716N/A<
P>AddHandler maps the filename extensions <
EM>extension</
EM> to the
716N/A<
EM>handler-name</
EM>. For example, to activate CGI scripts
716N/Awith the file extension "<
CODE>.cgi</
CODE>", you might use:
996N/A AddHandler cgi-script cgi
716N/Afile ending with "<
CODE>.cgi</
CODE>" will be treated as a CGI
716N/A<
H2><
A name="addlanguage">AddLanguage</
A></
H2>
996N/A<!--%plaintext <?INDEX {\tt AddLanguage} directive> --> 996N/A><
STRONG>Syntax:</
STRONG></
A> AddLanguage <
EM>mime-lang extension extension...</
EM><
BR>
716N/A><
STRONG>Context:</
STRONG></
A> server config, virtual host, directory, .htaccess<
BR>
716N/A><
STRONG>Override:</
STRONG></
A> FileInfo<
BR>
1102N/A><
STRONG>Status:</
STRONG></
A> Base<
BR>
732N/A><
STRONG>Module:</
STRONG></
A> mod_mime<
P>
732N/AThe AddLanguage directive adds to the list of filename extensions which
732N/Afilenames may end in for the specified content language. <
EM>Mime-lang</
EM>
732N/Ais the mime language of files with names ending <
EM>extension</
EM>,
732N/Aafter any content encoding extensions have been removed. Example:
732N/AAddEncoding x-compress Z<
BR>
732N/AThen the document <
CODE>
xxxx.
en.
Z</
CODE> will be treated as being a compressed
732N/AEnglish document. Although the content language is reported to the client,
732N/Athe browser is unlikely to use this information. The AddLanguage directive
732N/Ais more useful for content negotiation, where the server returns one
732N/Afrom several documents based on the client's language preference.<
P><
HR>
732N/A<
H2><
A name="addtype">AddType</
A></
H2>
732N/A<!--%plaintext <?INDEX {\tt AddType} directive> --> 732N/A><
STRONG>Syntax:</
STRONG></
A> AddType <
EM>mime-type extension extension...</
EM><
BR>
732N/A><
STRONG>Context:</
STRONG></
A> server config, virtual host, directory, .htaccess<
BR>
1102N/A><
STRONG>Override:</
STRONG></
A> FileInfo<
BR>
1102N/A><
STRONG>Status:</
STRONG></
A> Base<
BR>
1102N/A><
STRONG>Module:</
STRONG></
A> mod_mime<
P>
1102N/AThe AddType directive adds to the list of filename extensions which
1102N/Afilenames may end in for the specified content type. <
EM>Mime-enc</
EM>
1102N/Ais the mime type to use for documents ending in <
EM>extension</
EM>.
1102N/Aafter content-encoding and language extensions have been removed. Example:
1102N/AIt is recommended that new mime types be added using the AddType directive
1102N/Arather than changing the <
A HREF="#typesconfig">TypesConfig</
A> file.<
P>
1102N/ANote that, unlike the NCSA httpd, this directive cannot be used to set the
1102N/Atype of particular files.<
P><
HR>
1102N/A<
H2><
A name="forcetype">ForceType</
A></
H2>
1102N/A><
STRONG>Syntax:</
STRONG></
A> ForceType <
EM>media type</
EM><
BR>
1102N/A><
STRONG>Context:</
STRONG></
A> directory, .htaccess<
BR>
1102N/A><
STRONG>Status:</
STRONG></
A> Base<
BR>
1102N/A><
STRONG>Module:</
STRONG></
A> mod_mime<
BR>
1102N/A><
STRONG>Compatibility:</
STRONG></
A> ForceType is only available in Apache
1102N/A<
P>When placed into an <
CODE>.htaccess</
CODE> file or a
1102N/A<
CODE><Directory></
CODE> or <
CODE><Location></
CODE> section,
1102N/Athis directive forces all matching files to be served
1102N/Aas the content type given by <
EM>media type</
EM>. For example, if you
1102N/Ahad a directory full of GIF files, but did not want to label them all with
1102N/A".gif", you might want to use:
1102N/A<
P>Note that this will override any filename extensions that might
1102N/A<
H2><
A name="sethandler">SetHandler</
A></
H2>
><
STRONG>Syntax:</
STRONG></
A> SetHandler <
EM>handler-name</
EM><
BR>
><
STRONG>Context:</
STRONG></
A> directory, .htaccess<
BR>
><
STRONG>Status:</
STRONG></
A> Base<
BR>
><
STRONG>Module:</
STRONG></
A> mod_mime<
BR>
><
STRONG>Compatibility:</
STRONG></
A> SetHandler is only available in Apache
<
P>When placed into an <
CODE>.htaccess</
CODE> file or a
<
CODE><Directory></
CODE> or <
CODE><Location></
CODE> section,
this directive forces all matching files to be parsed through the
given by <
EM>handler-name</
EM>. For example, if you had a
directory you wanted to be parsed entirely as imagemap rule files,
regardless of extension, you might put the following into an
<
CODE>.htaccess</
CODE> file in that directory:
<
P>Another example: if you wanted to have the server display a status
<
H2><
A name="typesconfig">TypesConfig</
A></
H2>
<!--%plaintext <?INDEX {\tt TypesConfig} directive> --> ><
STRONG>Syntax:</
STRONG></
A> TypesConfig <
EM>filename</
EM><
BR>
><
STRONG>Default:</
STRONG></
A> <
CODE>TypesConfig
conf/
mime.types</
CODE><
BR>
><
STRONG>Context:</
STRONG></
A> server config<
BR>
><
STRONG>Status:</
STRONG></
A> Base<
BR>
><
STRONG>Module:</
STRONG></
A> mod_mime<
P>
The TypesConfig directive sets the location of the mime types configuration
file. <
EM>Filename</
EM> is relative to the
<
A HREF="core.html#serverroot">ServerRoot</
A>. This file sets the default list of
mappings from filename extensions to content types; changing this file is not
recommended. Use the <
A HREF="#addtype">AddType</
A> directive instead. The
file contains lines in the format of the arguments to an AddType command:
<
BLOCKQUOTE><
EM>mime-type extension extension ...</
EM></
BLOCKQUOTE>
The extensions are lower-cased. Blank lines, and lines beginning with a hash
character (`#') are ignored.<
P>