mod_mime.html revision e15efb65133619d06600dc277d340e8101a2f443
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<HTML>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<HEAD>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<TITLE>Apache module mod_mime</TITLE>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier</HEAD>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<BODY>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<!--#include virtual="header.html" -->
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<H1>Module mod_mime</h1>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier
60a4b2c422dcbb08a554fb193105c08da592718bpoirierThis module is contained in the <code>mod_mime.c</code> file, and is
60a4b2c422dcbb08a554fb193105c08da592718bpoiriercompiled in by default. It provides for determining the types of files
60a4b2c422dcbb08a554fb193105c08da592718bpoirierfrom the filename.
60a4b2c422dcbb08a554fb193105c08da592718bpoirier
3f08db06526d6901aa08c110b5bc7dde6bc39905nd<h2>Summary</h2>
60a4b2c422dcbb08a554fb193105c08da592718bpoirierThis module is used to determine the mime types of documents. Some mime
60a4b2c422dcbb08a554fb193105c08da592718bpoiriertypes indicate special processing to be performed by the server, otherwise
60a4b2c422dcbb08a554fb193105c08da592718bpoirierthe type is returned to the client so that the browser can deal with
3f08db06526d6901aa08c110b5bc7dde6bc39905ndthe document appropriately.<p>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjungThe filename of a document is treated as being composed of a basename followed
60a4b2c422dcbb08a554fb193105c08da592718bpoirierby some extensions, in the following order:
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<blockquote><em>base.type.language.enc</em></blockquote>
60a4b2c422dcbb08a554fb193105c08da592718bpoirierThe <em>type</em> extension sets the type of the document; types are defined
60a4b2c422dcbb08a554fb193105c08da592718bpoirierin the <A HREF="#typesconfig">TypesConfig</A> file and by the
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<A HREF="#addtype">AddType</A> directive. The <em>language</em> extension
60a4b2c422dcbb08a554fb193105c08da592718bpoiriersets the language of the document, as defined by the
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<A HREF="#addlanguage">AddLanguage</A> directive. Finally, the
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<em>enc</em> directive sets the encoding of the document, as defined by
60a4b2c422dcbb08a554fb193105c08da592718bpoirierthe <A HREF="#addencoding">AddEncoding</A> directive.
60a4b2c422dcbb08a554fb193105c08da592718bpoirier
60a4b2c422dcbb08a554fb193105c08da592718bpoirier
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<h2> Directives</h2>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<ul>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<li><A HREF="#addencoding">AddEncoding</A>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<li><A HREF="#addhandler">AddHandler</A>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<li><A HREF="#addlanguage">AddLanguage</A>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<li><A HREF="#addtype">AddType</A>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<li><A HREF="#forcetype">ForceType</A>
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf<li><A HREF="#sethandler">SetHandler</A>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<li><A HREF="#typesconfig">TypesConfig</A>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier</ul>
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<hr>
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf
60a4b2c422dcbb08a554fb193105c08da592718bpoirier
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<h2><A name="addencoding">AddEncoding</A></h2>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<!--%plaintext &lt;?INDEX {\tt AddEncoding} directive&gt; -->
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<strong>Syntax:</strong> AddEncoding <em>mime-enc extension extension...</em><br>
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<Strong>Context:</strong> server config, virtual host, directory, .htaccess<br>
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<Strong>Override:</strong> FileInfo<br>
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<strong>Status:</strong> Base<br>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<strong>Module:</strong> mod_mime<p>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier
60a4b2c422dcbb08a554fb193105c08da592718bpoirierThe AddEncoding directive adds to the list of filename extensions which
60a4b2c422dcbb08a554fb193105c08da592718bpoirierfilenames may end in for the specified encoding type. <em>Mime-enc</em>
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sfis the mime encoding to use for documents ending in <em>extension</em>.
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sfExample:
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<blockquote><code>
60a4b2c422dcbb08a554fb193105c08da592718bpoirierAddEncoding x-gzip gz<br>
60a4b2c422dcbb08a554fb193105c08da592718bpoirierAddEncoding x-compress Z
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf</code></blockquote>
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sfThis will cause files ending in .gz to be marked as encoded using the x-gzip
60a4b2c422dcbb08a554fb193105c08da592718bpoirierencoding, and .Z files to be marked as encoded with x-compress.<p><hr>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<h2><a name="addhandler">AddHandler</a></h2>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<strong>Syntax:</strong> &lt;AddHandler <em>handler-name extension</em>&gt;<br>
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<strong>Context:</strong> server config, virtual host, directory, .htaccess<br>
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<strong>Status:</strong> Base<br>
a04dcd330b05345681a4057702b2d43b2042e21dtrawick<strong>Module:</strong> mod_mime<br>
a04dcd330b05345681a4057702b2d43b2042e21dtrawick<strong>Compatibility:</strong> AddHandler is only available in Apache
a04dcd330b05345681a4057702b2d43b2042e21dtrawick1.1 and later<p>
a04dcd330b05345681a4057702b2d43b2042e21dtrawick
f8b7daeb0e3f0ac4544fcc665de10c6b69a1ce0dsf<p>AddHandler maps the filename extension <em>extension</em> to the
f8b7daeb0e3f0ac4544fcc665de10c6b69a1ce0dsf<a href="/handler.html">handler</a>
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<em>handler-name</em>. For example, to activate CGI scripts
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sfwith the file extension "<code>.cgi</code>", you might use:
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<pre>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier AddHandler cgi-script cgi
60a4b2c422dcbb08a554fb193105c08da592718bpoirier</pre>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<p>Once that has been put into your srm.conf or httpd.conf file, any
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sffile ending with "<code>.cgi</code>" will be treated as a CGI
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sfprogram.</p>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<HR>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<h2><A name="addlanguage">AddLanguage</A></h2>
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<!--%plaintext &lt;?INDEX {\tt AddLanguage} directive&gt; -->
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<strong>Syntax:</strong> AddLanguage <em>mime-lang extension extension...</em><br>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<Strong>Context:</strong> server config, virtual host, directory, .htaccess<br>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<Strong>Override:</strong> FileInfo<br>
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<strong>Status:</strong> Base<br>
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<strong>Module:</strong> mod_mime<p>
bed3c2e56e8f3328e780200466b9d009093db468sf
bed3c2e56e8f3328e780200466b9d009093db468sfThe AddLanguage directive adds to the list of filename extensions which
bed3c2e56e8f3328e780200466b9d009093db468sffilenames may end in for the specified content language. <em>Mime-lang</em>
bed3c2e56e8f3328e780200466b9d009093db468sfis the mime language of files with names ending <em>extension</em>,
bed3c2e56e8f3328e780200466b9d009093db468sfafter any content encoding extensions have been removed. Example:
bed3c2e56e8f3328e780200466b9d009093db468sf<blockquote><code>
bed3c2e56e8f3328e780200466b9d009093db468sfAddEncoding x-compress Z<br>
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sfAddLanguage en .en<br>
60a4b2c422dcbb08a554fb193105c08da592718bpoirierAddLanguage fr .fr<br>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier</code></blockquote>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier
60a4b2c422dcbb08a554fb193105c08da592718bpoirierThen the document <code>xxxx.en.Z</code> will be treated as being a compressed
60a4b2c422dcbb08a554fb193105c08da592718bpoirierEnglish document. Although the content language is reported to the client,
60a4b2c422dcbb08a554fb193105c08da592718bpoirierthe browser is unlikely to use this information. The AddLanguage directive
60a4b2c422dcbb08a554fb193105c08da592718bpoirieris more useful for content negotiation, where the server returns one
60a4b2c422dcbb08a554fb193105c08da592718bpoirierfrom several documents based on the client's language preference.<p><hr>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier
fe1c96d8f3b0c1f7e75eb8feb0170432bd91c951sf<h2><A name="addtype">AddType</A></h2>
fe1c96d8f3b0c1f7e75eb8feb0170432bd91c951sf<!--%plaintext &lt;?INDEX {\tt AddType} directive&gt; -->
bcb2c4ef861e8f8260284631b6753e1088643c8asf<strong>Syntax:</strong> AddType <em>mime-type extension extension...</em><br>
bcb2c4ef861e8f8260284631b6753e1088643c8asf<Strong>Context:</strong> server config, virtual host, directory, .htaccess<br>
bcb2c4ef861e8f8260284631b6753e1088643c8asf<Strong>Override:</strong> FileInfo<br>
bcb2c4ef861e8f8260284631b6753e1088643c8asf<strong>Status:</strong> Base<br>
bcb2c4ef861e8f8260284631b6753e1088643c8asf<strong>Module:</strong> mod_mime<p>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sfThe AddType directive adds to the list of filename extensions which
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sffilenames may end in for the specified content type. <em>Mime-enc</em>
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sfis the mime type to use for documents ending in <em>extension</em>.
60a4b2c422dcbb08a554fb193105c08da592718bpoirierafter content-encoding and language extensions have been removed. Example:
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<blockquote><code>
60a4b2c422dcbb08a554fb193105c08da592718bpoirierAddType image/gif GIF
60a4b2c422dcbb08a554fb193105c08da592718bpoirier</code></blockquote>
60a4b2c422dcbb08a554fb193105c08da592718bpoirierIt is recommended that new mime types be added using the AddType directive
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sfrather than changing the <A HREF="#typesconfig">TypesConfig</A> file.<p>
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sfNote that, unlike the NCSA httpd, this directive cannot be used to set the
d474d8ef01ec5c2a09341cd148851ed383c3287crbowentype of particular files.<p><hr>
d474d8ef01ec5c2a09341cd148851ed383c3287crbowen
d474d8ef01ec5c2a09341cd148851ed383c3287crbowen<h2><a name="forcetype">ForceType</a></h2>
d474d8ef01ec5c2a09341cd148851ed383c3287crbowen
0236ede61169f34359c234625a1d792b97d7db12nd<strong>Syntax:</strong> &lt;ForceType <em>media type</em>&gt;<br>
0236ede61169f34359c234625a1d792b97d7db12nd<strong>Context:</strong> directory, .htaccess<br>
0236ede61169f34359c234625a1d792b97d7db12nd<strong>Status:</strong> Base<br>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<strong>Module:</strong> mod_mime<br>
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<strong>Compatibility:</strong> ForceType is only available in Apache
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf1.1 and later.<p>
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<p>When placed into an <code>.htaccess</code> file or a
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<code>&lt;Directory&gt;</code> or <code>&lt;Location</code> section,
60a4b2c422dcbb08a554fb193105c08da592718bpoirierthis directive forces all matching files to be served
60a4b2c422dcbb08a554fb193105c08da592718bpoirieras the content type given by <em>media type</em>. For example, if you
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sfhad a directory full of GIF files, but did not want to label them all with
60a4b2c422dcbb08a554fb193105c08da592718bpoirier".gif", you might want to use:
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<pre>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier ForceType image/gif
fed47023e9be04c612b5f6d4a5ee2b8e7c587181rbowen</pre>
fed47023e9be04c612b5f6d4a5ee2b8e7c587181rbowen<p>Note that this will override any filename extensions that might
fed47023e9be04c612b5f6d4a5ee2b8e7c587181rbowenmedia type.</p>
fed47023e9be04c612b5f6d4a5ee2b8e7c587181rbowen
fed47023e9be04c612b5f6d4a5ee2b8e7c587181rbowen<h2><a name="sethandler">SetHandler</a></h2>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<strong>Syntax:</strong> &lt;SetHandler <em>handler-name</em>&gt;<br>
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<strong>Context:</strong> directory, .htaccess<br>
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<strong>Status:</strong> Base<br>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<strong>Module:</strong> mod_mime<br>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<strong>Compatibility:</strong> SetHandler is only available in Apache
60a4b2c422dcbb08a554fb193105c08da592718bpoirier1.1 and later.<p>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<p>When placed into an <code>.htaccess</code> file or a
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<code>&lt;Directory&gt;</code> or <code>&lt;Location</code> section,
60a4b2c422dcbb08a554fb193105c08da592718bpoirierthis directive forces all matching files to be parsed through the
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<a href="/handler.html">handler</a>
60a4b2c422dcbb08a554fb193105c08da592718bpoiriergiven by <em>handler-name</em>. For example, if you had a
60a4b2c422dcbb08a554fb193105c08da592718bpoirierdirectory you wanted to be parsed entirely as imagemap rule files,
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sfregardless of extension, you might put the following into an
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<code>.htaccess</code> file in that directory:
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<pre>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier SetHandler imap-file
60a4b2c422dcbb08a554fb193105c08da592718bpoirier</pre>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<p>Another example: if you wanted to have the server display a status
60a4b2c422dcbb08a554fb193105c08da592718bpoirierreport whenever a URL of <code>http://servername/status</code> was
60a4b2c422dcbb08a554fb193105c08da592718bpoiriercalled, you might put the following into access.conf:
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<pre>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier &lt;Location /status&gt;
60a4b2c422dcbb08a554fb193105c08da592718bpoirier SetHandler server-status
60a4b2c422dcbb08a554fb193105c08da592718bpoirier &lt;/Location&gt;
60a4b2c422dcbb08a554fb193105c08da592718bpoirier</pre>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<HR>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<h2><A name="typesconfig">TypesConfig</A></h2>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<!--%plaintext &lt;?INDEX {\tt TypesConfig} directive&gt; -->
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<strong>Syntax:</strong> TypesConfig <em>filename</em><br>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<strong>Default:</strong> <code>TypesConfig conf/mime.types</code><br>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<Strong>Context:</strong> server config<br>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<strong>Status:</strong> Base<br>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<strong>Module:</strong> mod_mime<p>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier
60a4b2c422dcbb08a554fb193105c08da592718bpoirierThe TypesConfig directive sets the location of the mime types configuration
60a4b2c422dcbb08a554fb193105c08da592718bpoirierfile. <em>Filename</em> is relative to the
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<A HREF="core.html#serverroot">ServerRoot</A>. This file sets the default list of
60a4b2c422dcbb08a554fb193105c08da592718bpoiriermappings from filename extensions to content types; changing this file is not
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sfrecommended. Use the <A HREF="#addtype">AddType</A> directive instead. The
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sffile contains lines in the format of the arguments to an AddType command:
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<blockquote><em>mime-type extension extension ...</em></blockquote>
60a4b2c422dcbb08a554fb193105c08da592718bpoirierThe extensions are lower-cased. Blank lines, and lines beginning with a hash
60a4b2c422dcbb08a554fb193105c08da592718bpoiriercharacter (`#') are ignored.<p>
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<!--#include virtual="footer.html" -->
b6529ec5115d80b7dedcfd0935746015b2096084minfrin</BODY>
b6529ec5115d80b7dedcfd0935746015b2096084minfrin</HTML>
b6529ec5115d80b7dedcfd0935746015b2096084minfrin
b6529ec5115d80b7dedcfd0935746015b2096084minfrin