mod_mime.html revision 6fbf10ebad03aa5f5c38086f9cf39ad917487113
409N/A<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
50N/A<HTML>
50N/A<HEAD>
50N/A<TITLE>Apache module mod_mime</TITLE>
50N/A</HEAD>
50N/A
50N/A<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
50N/A<BODY
50N/A BGCOLOR="#FFFFFF"
50N/A TEXT="#000000"
50N/A LINK="#0000FF"
50N/A VLINK="#000080"
50N/A ALINK="#FF0000"
50N/A>
50N/A<!--#include virtual="header.html" -->
50N/A<H1 ALIGN="CENTER">Module mod_mime</h1>
50N/A
50N/AThis module is contained in the <code>mod_mime.c</code> file, and is
50N/Acompiled in by default. It provides for determining the types of files
50N/Afrom the filename.
50N/A
50N/A<h2>Summary</h2>
289N/A
50N/AThis module is used to determine various bits of "meta information"
50N/Aabout documents. This information relates to the content of the
60N/Adocument and is returned to the browser or used in content-negotiation
202N/Awithin the server. In addition, a "handler" can be set for a document,
50N/Awhich determines how the document will be processed within the server.
50N/A
72N/A<P>
119N/A
307N/AThe directives <A HREF="#addencoding">AddEncoding</A>, <A
384N/AHREF="#addhandler">AddHandler</A>, <A
487N/AHREF="#addlanguage">AddLanguage</A> and <A HREF="#addtype">AddType</A>
838N/Aare all used to map file extensions onto the meta-information for that
956N/Afile. Respectively they set the content-encoding, handler,
50N/Acontent-language and mime-type (content-type) of documents. The
50N/Adirective <A HREF="#typesconfig">TypesConfig</A> is used to specify a
50N/Afile which also maps extensions onto mime types. The directives <A
50N/AHREF="#forcetype">ForceType</A> and <A
66N/AHREF="#sethandler">SetHandler</A> are used to associated all the files
135N/Ain a given location (e.g. a particular directory) onto a particular
66N/Amime type or handler.
66N/A
50N/A<P>
580N/A
50N/AFiles can have more than one extension, and the order of the
50N/Aextensions is normally irrelevant. For example, if the file
400N/A<CODE>welcome.html.fr</CODE> maps onto content type text/html and
583N/Alanguage French then the file <CODE>welcome.fr.html</CODE> will map
400N/Aonto exactly the same information. The only exception to this is if an
964N/Aextension is given which Apache does not know how to handle. In this
964N/Acase it will "forget" about any information it obtained from
400N/Aextensions to the left of the unknown extension. So, for example, if
50N/Athe extensions fr and html are mapped to the appropriate language and
50N/Atype but extension xxx is not assigned to anything, then the file
400N/A<CODE>welcome.fr.xxx.html</CODE> will be associated with content-type
50N/Atext/html but <i>no</i> language.
400N/A
400N/A<P>
235N/A
400N/A<h2> Directives</h2>
242N/A<ul>
580N/A<li><A HREF="#addencoding">AddEncoding</A>
580N/A<li><A HREF="#addhandler">AddHandler</A>
63N/A<li><A HREF="#addlanguage">AddLanguage</A>
72N/A<li><A HREF="#addtype">AddType</A>
72N/A<li><A HREF="#forcetype">ForceType</A>
202N/A<li><A HREF="#sethandler">SetHandler</A>
72N/A<li><A HREF="#typesconfig">TypesConfig</A>
72N/A</ul>
72N/A<hr>
63N/A
583N/A
583N/A<h2><A name="addencoding">AddEncoding</A></h2>
583N/A<!--%plaintext &lt;?INDEX {\tt AddEncoding} directive&gt; -->
1003N/A<strong>Syntax:</strong> AddEncoding <em>mime-enc extension extension...</em><br>
583N/A<Strong>Context:</strong> server config, virtual host, directory, .htaccess<br>
583N/A<Strong>Override:</strong> FileInfo<br>
583N/A<strong>Status:</strong> Base<br>
583N/A<strong>Module:</strong> mod_mime<p>
583N/A
583N/AThe AddEncoding directive adds to the list of filename extensions which
583N/Afilenames may end in for the specified encoding type. <em>Mime-enc</em>
583N/Ais the mime encoding to use for documents ending in <em>extension</em>.
583N/AExample:
583N/A<blockquote><code>
583N/AAddEncoding x-gzip gz<br>
242N/AAddEncoding x-compress Z
50N/A</code></blockquote>
400N/A
400N/AThis will cause files ending in .gz to be marked as encoded using the x-gzip
50N/Aencoding, and .Z files to be marked as encoded with x-compress.<p><hr>
195N/A
59N/A<h2><a name="addhandler">AddHandler</a></h2>
59N/A
242N/A<strong>Syntax:</strong> AddHandler <em>handler-name extension extension...</em><br>
66N/A<strong>Context:</strong> server config, virtual host, directory, .htaccess<br>
400N/A<strong>Status:</strong> Base<br>
66N/A<strong>Module:</strong> mod_mime<br>
195N/A<strong>Compatibility:</strong> AddHandler is only available in Apache
66N/A1.1 and later<p>
66N/A
50N/A<p>AddHandler maps the filename extensions <em>extension</em> to the
235N/A<a href="/handler.html">handler</a>
235N/A<em>handler-name</em>. For example, to activate CGI scripts
235N/Awith the file extension "<code>.cgi</code>", you might use:
235N/A<pre>
235N/A AddHandler cgi-script cgi
50N/A</pre>
307N/A
307N/A<p>Once that has been put into your srm.conf or httpd.conf file, any
307N/Afile ending with "<code>.cgi</code>" will be treated as a CGI
307N/Aprogram.</p>
307N/A<HR>
307N/A
307N/A<h2><A name="addlanguage">AddLanguage</A></h2>
307N/A<!--%plaintext &lt;?INDEX {\tt AddLanguage} directive&gt; -->
307N/A<strong>Syntax:</strong> AddLanguage <em>mime-lang extension extension...</em><br>
307N/A<Strong>Context:</strong> server config, virtual host, directory, .htaccess<br>
838N/A<Strong>Override:</strong> FileInfo<br>
66N/A<strong>Status:</strong> Base<br>
50N/A<strong>Module:</strong> mod_mime<p>
50N/A
66N/AThe AddLanguage directive adds to the list of filename extensions which
66N/Afilenames may end in for the specified content language. <em>Mime-lang</em>
66N/Ais the mime language of files with names ending <em>extension</em>,
50N/Aafter any content encoding extensions have been removed. Example:
838N/A<blockquote><code>
72N/AAddEncoding x-compress Z<br>
258N/AAddLanguage en .en<br>
258N/AAddLanguage fr .fr<br>
258N/A</code></blockquote>
59N/A
400N/AThen the document <code>xxxx.en.Z</code> will be treated as being a compressed
400N/AEnglish document. Although the content language is reported to the client,
50N/Athe browser is unlikely to use this information. The AddLanguage directive
111N/Ais more useful for content negotiation, where the server returns one
111N/Afrom several documents based on the client's language preference.<p><hr>
838N/A
111N/A<h2><A name="addtype">AddType</A></h2>
111N/A<!--%plaintext &lt;?INDEX {\tt AddType} directive&gt; -->
111N/A<strong>Syntax:</strong> AddType <em>mime-type extension extension...</em><br>
838N/A<Strong>Context:</strong> server config, virtual host, directory, .htaccess<br>
838N/A<Strong>Override:</strong> FileInfo<br>
50N/A<strong>Status:</strong> Base<br>
307N/A<strong>Module:</strong> mod_mime<p>
307N/A
307N/AThe AddType directive adds to the list of filename extensions which
307N/Afilenames may end in for the specified content type. <em>Mime-enc</em>
307N/Ais the mime type to use for documents ending in <em>extension</em>.
964N/Aafter content-encoding and language extensions have been removed. Example:
964N/A<blockquote><code>
964N/AAddType image/gif GIF
964N/A</code></blockquote>
964N/AIt is recommended that new mime types be added using the AddType directive
307N/Arather than changing the <A HREF="#typesconfig">TypesConfig</A> file.<p>
307N/ANote that, unlike the NCSA httpd, this directive cannot be used to set the
400N/Atype of particular files.<p><hr>
400N/A
307N/A<h2><a name="forcetype">ForceType</a></h2>
400N/A
400N/A<strong>Syntax:</strong> ForceType <em>media type</em><br>
400N/A<strong>Context:</strong> directory, .htaccess<br>
400N/A<strong>Status:</strong> Base<br>
583N/A<strong>Module:</strong> mod_mime<br>
583N/A<strong>Compatibility:</strong> ForceType is only available in Apache
583N/A1.1 and later.<p>
400N/A
400N/A<p>When placed into an <code>.htaccess</code> file or a
964N/A<code>&lt;Directory&gt;</code> or <code>&lt;Location&gt;</code> section,
964N/Athis directive forces all matching files to be served
400N/Aas the content type given by <em>media type</em>. For example, if you
400N/Ahad a directory full of GIF files, but did not want to label them all with
964N/A".gif", you might want to use:
964N/A<pre>
964N/A ForceType image/gif
964N/A</pre>
400N/A<p>Note that this will override any filename extensions that might
400N/Amedia type.</p>
400N/A
400N/A<h2><a name="sethandler">SetHandler</a></h2>
400N/A
400N/A<strong>Syntax:</strong> SetHandler <em>handler-name</em><br>
235N/A<strong>Context:</strong> directory, .htaccess<br>
400N/A<strong>Status:</strong> Base<br>
400N/A<strong>Module:</strong> mod_mime<br>
235N/A<strong>Compatibility:</strong> SetHandler is only available in Apache
400N/A1.1 and later.<p>
400N/A
235N/A<p>When placed into an <code>.htaccess</code> file or a
235N/A<code>&lt;Directory&gt;</code> or <code>&lt;Location&gt;</code> section,
487N/Athis directive forces all matching files to be parsed through the
400N/A<a href="/handler.html">handler</a>
235N/Agiven by <em>handler-name</em>. For example, if you had a
400N/Adirectory you wanted to be parsed entirely as imagemap rule files,
235N/Aregardless of extension, you might put the following into an
235N/A<code>.htaccess</code> file in that directory:
235N/A<pre>
235N/A SetHandler imap-file
235N/A</pre>
235N/A
235N/A<p>Another example: if you wanted to have the server display a status
235N/Areport whenever a URL of <code>http://servername/status</code> was
235N/Acalled, you might put the following into access.conf:
235N/A<pre>
235N/A &lt;Location /status&gt;
235N/A SetHandler server-status
235N/A &lt;/Location&gt;
235N/A</pre>
289N/A<HR>
50N/A
388N/A<h2><A name="typesconfig">TypesConfig</A></h2>
388N/A<!--%plaintext &lt;?INDEX {\tt TypesConfig} directive&gt; -->
135N/A<strong>Syntax:</strong> TypesConfig <em>filename</em><br>
66N/A<strong>Default:</strong> <code>TypesConfig conf/mime.types</code><br>
66N/A<Strong>Context:</strong> server config<br>
66N/A<strong>Status:</strong> Base<br>
66N/A<strong>Module:</strong> mod_mime<p>
111N/A
202N/AThe TypesConfig directive sets the location of the mime types configuration
72N/Afile. <em>Filename</em> is relative to the
136N/A<A HREF="core.html#serverroot">ServerRoot</A>. This file sets the default list of
66N/Amappings from filename extensions to content types; changing this file is not
136N/Arecommended. Use the <A HREF="#addtype">AddType</A> directive instead. The
66N/Afile contains lines in the format of the arguments to an AddType command:
481N/A<blockquote><em>mime-type extension extension ...</em></blockquote>
481N/AThe extensions are lower-cased. Blank lines, and lines beginning with a hash
481N/Acharacter (`#') are ignored.<p>
580N/A
481N/A<!--#include virtual="footer.html" -->
481N/A</BODY>
481N/A</HTML>
481N/A
481N/A