mod_mime.html revision 3d76f0e292da6a107829fbe83f98b8c0985c6ddb
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync<!--%hypertext -->
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync<HTML>
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync<HEAD>
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync<TITLE>Apache module mod_mime</TITLE>
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync</HEAD>
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync<BODY>
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync<IMG SRC="/images/apache_sub.gif" ALT="">
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync<!--/%hypertext -->
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync<H1>Module mod_mime</h1>
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncThis module is contained in the <code>mod_mime.c</code> file, and is
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsynccompiled in by default. It provides for determining the types of files
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncfrom the filename.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync<h2>Summary</h2>
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncThis module is used to determine the mime types of documents. Some mime
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsynctypes indicate special processing to be performed by the server, otherwise
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncthe type is returned to the client so that the browser can deal with
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncthe document appropriately.<p>
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncThe filename of a document is treated as being composed of a basename followed
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncby some extensions, in the following order:
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync<blockquote><em>base.type.language.enc</em></blockquote>
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncThe <em>type</em> extension sets the type of the document; types are defined
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncin the <A HREF="#typesconfig">TypesConfig</A> file and by the
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync<A HREF="#addtype">AddType</A> directive. The <em>language</em> extension
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncsets the language of the document, as defined by the
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync<A HREF="#addlanguage">AddLanguage</A> directive. Finally, the
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync<em>enc</em> directive sets the encoding of the document, as defined by
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsyncthe <A HREF="#addencoding">AddEncoding</A> directive.
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync<!--%hypertext -->
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync<h2> Directives</h2>
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync<ul>
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync<li><A HREF="#addencoding">AddEncoding</A>
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync<li><A HREF="#addhandler">AddHandler</A>
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync<li><A HREF="#addlanguage">AddLanguage</A>
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync<li><A HREF="#addtype">AddType</A>
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync<li><A HREF="#forcetype">ForceType</A>
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync<li><A HREF="#sethandler">SetHandler</A>
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync<li><A HREF="#typesconfig">TypesConfig</A>
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync</ul>
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync<hr>
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync<!--/%hypertext -->
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync<A name="addencoding"><h2>AddEncoding</h2></A>
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync<!--%plaintext &lt;?INDEX {\tt AddEncoding} directive&gt; -->
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync<strong>Syntax:</strong> AddEncoding <em>mime-enc extension extension...</em><br>
b8e299dddd091ae24e0c08c45d91b8f937bd14d2vboxsync<Strong>Context:</strong> server config, virtual host, directory, .htaccess<br>
<Strong>Override:</strong> FileInfo<br>
<strong>Status:</strong> Base<br>
<strong>Module:</strong> mod_mime<p>
The AddEncoding directive adds to the list of filename extensions which
filenames may end in for the specified encoding type. <em>Mime-enc</em>
is the mime encoding to use for documents ending in <em>extension</em>.
Example:
<blockquote><code>
AddEncoding x-gzip gz<br>
AddEncoding x-compress Z
</code></blockquote>
This will cause files ending in .gz to be marked as encoded using the x-gzip
encoding, and .Z files to be marked as encoded with x-compress.<p><hr>
<h2><a name="addhandler">AddHandler</a></h2>
<strong>Syntax:</strong> &lt;AddHandler <em>handler-name extention</em>&gt;<br>
<strong>Context:</strong> server config, virtual host, directory, .htaccess<br>
<strong>Status:</strong> Base<br>
<strong>Module:</strong> mod_mime<br>
<strong>Compatibility:</strong> AddHandler is only available in Apache
1.1 and later<p>
<p>AddHandler maps the filename extension <em>extension</em> to the
<a href="handler.html">handler</a>
<em>handler-name</em>. For example, to activate CGI scripts
with the file extension "<code>.cgi</code>", you might use:
<pre>
AddHandler cgi-script cgi
</pre>
<p>Once that has been put into your srm.conf or httpd.conf file, any
file ending with "<code>.cgi</code>" will be treated as a CGI
program.</p>
<A name="addlanguage"><h2>AddLanguage</h2></A>
<!--%plaintext &lt;?INDEX {\tt AddLanguage} directive&gt; -->
<strong>Syntax:</strong> AddLanguage <em>mime-lang extension extension...</em><br>
<Strong>Context:</strong> server config, virtual host, directory, .htaccess<br>
<Strong>Override:</strong> FileInfo<br>
<strong>Status:</strong> Base<br>
<strong>Module:</strong> mod_mime<p>
The AddLanguage directive adds to the list of filename extensions which
filenames may end in for the specified content language. <em>Mime-lang</em>
is the mime language of files with names ending <em>extension</em>,
after any content encoding extensions have been removed. Example:
<blockquote><code>
AddEncoding x-compress Z<br>
AddLanguage en .en<br>
AddLanguage fr .fr<br>
</code></blockquote>
Then the document <code>xxxx.en.Z</code> will be treated as being a compressed
English document. Although the content language is reported to the client,
the browser is unlikely to use this information. The AddLanguage directive
is more useful for content negotiation, where the server returns one
from several documents based on the client's language preference.<p><hr>
<A name="addtype"><h2>AddType</h2></A>
<!--%plaintext &lt;?INDEX {\tt AddType} directive&gt; -->
<strong>Syntax:</strong> AddType <em>mime-type extension extension...</em><br>
<Strong>Context:</strong> server config, virtual host, directory, .htaccess<br>
<Strong>Override:</strong> FileInfo<br>
<strong>Status:</strong> Base<br>
<strong>Module:</strong> 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:
<blockquote><code>
AddType image/gif GIF
</code></blockquote>
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="sethandler">ForceType</a></h2>
<strong>Syntax:</strong> &lt;ForceType <em>media type</em>&gt;<br>
<strong>Context:</strong> directory, .htaccess<br>
<strong>Status:</strong> Base<br>
<strong>Module:</strong> mod_mime<br>
<strong>Compatibility:</strong> ForceType is only available in Apache
1.1 and later.<p>
<p>When placed into an <code>.htaccess</code> file or a
<code>&lt;Directory&gt;</code> or <code>&lt;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:
<pre>
ForceType image/gif
</pre>
<p>Note that this will override any filename extensions that might
media type.</p>
<h2><a name="sethandler">SetHandler</a></h2>
<strong>Syntax:</strong> &lt;SetHandler <em>handler-name</em>&gt;<br>
<strong>Context:</strong> directory, .htaccess<br>
<strong>Status:</strong> Base<br>
<strong>Module:</strong> mod_mime<br>
<strong>Compatibility:</strong> SetHandler is only available in Apache
1.1 and later.<p>
<p>When placed into an <code>.htaccess</code> file or a
<code>&lt;Directory&gt;</code> or <code>&lt;Location</code> section,
this directive forces all matching files to be parsed through the
<a href="handler.html">handler</a>
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:
<pre>
SetHandler imap-file
</pre>
<p>Another example: if you wanted to have the server display a status
report whenever a URL of <code>http://servername/status</code> was
called, you might put the following into access.conf:
<pre>
&lt;Location /status&gt;
SetHandler server-status
&lt;/Location&gt;
</pre>
<A name="typesconfig"><h2>TypesConfig</h2></A>
<!--%plaintext &lt;?INDEX {\tt TypesConfig} directive&gt; -->
<strong>Syntax:</strong> TypesConfig <em>filename</em><br>
<strong>Default:</strong> <code>TypesConfig conf/mime.types</code><br>
<Strong>Context:</strong> server config<br>
<strong>Status:</strong> Base<br>
<strong>Module:</strong> mod_mime<p>
The TypesConfig directive sets the location of the mime types configuration
file. <em>Filename</em> is relative to the
<A HREF="#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>
<!--%hypertext -->
<hr>
<A HREF="../"><IMG SRC="/images/apache_home.gif" ALT="Home"></A>
<A HREF="./"><IMG SRC="/images/apache_index.gif" ALT="Index"></A>
</BODY>
</HTML>
<!--/%hypertext -->