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