mod_mime.html revision ab7592b7be071922570a15757888f004e2ec44c9
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<!--#include virtual="header.html" -->
33093f5bcdc51014933497dd39374080c1ac5705Bryan CantrillThis module is contained in the <code>mod_mime.c</code> file, and is
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrillcompiled in by default. It provides for determining the types of files
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrillfrom the filename.
33093f5bcdc51014933497dd39374080c1ac5705Bryan CantrillThis module is used to determine the mime types of documents. Some mime
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrilltypes indicate special processing to be performed by the server, otherwise
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrillthe type is returned to the client so that the browser can deal with
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrillthe document appropriately.<p>
33093f5bcdc51014933497dd39374080c1ac5705Bryan CantrillThe filename of a document is treated as being composed of a basename followed
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrillby some extensions, in the following order:
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<blockquote><em>base.type.language.enc</em></blockquote>
33093f5bcdc51014933497dd39374080c1ac5705Bryan CantrillThe <em>type</em> extension sets the type of the document; types are defined
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrillin the <A HREF="#typesconfig">TypesConfig</A> file and by the
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<A HREF="#addtype">AddType</A> directive. The <em>language</em> extension
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrillsets the language of the document, as defined by the
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<A HREF="#addlanguage">AddLanguage</A> directive. Finally, the
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<em>enc</em> directive sets the encoding of the document, as defined by
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrillthe <A HREF="#addencoding">AddEncoding</A> directive.
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<A name="addencoding"><h2>AddEncoding</h2></A>
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<!--%plaintext <?INDEX {\tt AddEncoding} directive> -->
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<strong>Syntax:</strong> AddEncoding <em>mime-enc extension extension...</em><br>
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<Strong>Context:</strong> server config, virtual host, directory, .htaccess<br>
33093f5bcdc51014933497dd39374080c1ac5705Bryan CantrillThe AddEncoding directive adds to the list of filename extensions which
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrillfilenames may end in for the specified encoding type. <em>Mime-enc</em>
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrillis the mime encoding to use for documents ending in <em>extension</em>.
33093f5bcdc51014933497dd39374080c1ac5705Bryan CantrillAddEncoding x-gzip gz<br>
33093f5bcdc51014933497dd39374080c1ac5705Bryan CantrillAddEncoding x-compress Z
33093f5bcdc51014933497dd39374080c1ac5705Bryan CantrillThis will cause files ending in .gz to be marked as encoded using the x-gzip
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrillencoding, and .Z files to be marked as encoded with x-compress.<p><hr>
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<strong>Syntax:</strong> <AddHandler <em>handler-name extension</em>><br>
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<strong>Context:</strong> server config, virtual host, directory, .htaccess<br>
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<strong>Compatibility:</strong> AddHandler is only available in Apache
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill1.1 and later<p>
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<p>AddHandler maps the filename extension <em>extension</em> to the
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<em>handler-name</em>. For example, to activate CGI scripts
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrillwith the file extension "<code>.cgi</code>", you might use:
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill AddHandler cgi-script cgi
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<p>Once that has been put into your srm.conf or httpd.conf file, any
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrillfile ending with "<code>.cgi</code>" will be treated as a CGI
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<A name="addlanguage"><h2>AddLanguage</h2></A>
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<!--%plaintext <?INDEX {\tt AddLanguage} directive> -->
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<strong>Syntax:</strong> AddLanguage <em>mime-lang extension extension...</em><br>
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<Strong>Context:</strong> server config, virtual host, directory, .htaccess<br>
33093f5bcdc51014933497dd39374080c1ac5705Bryan CantrillThe AddLanguage directive adds to the list of filename extensions which
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrillfilenames may end in for the specified content language. <em>Mime-lang</em>
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrillis the mime language of files with names ending <em>extension</em>,
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrillafter any content encoding extensions have been removed. Example:
33093f5bcdc51014933497dd39374080c1ac5705Bryan CantrillAddEncoding x-compress Z<br>
33093f5bcdc51014933497dd39374080c1ac5705Bryan CantrillAddLanguage en .en<br>
33093f5bcdc51014933497dd39374080c1ac5705Bryan CantrillAddLanguage fr .fr<br>
33093f5bcdc51014933497dd39374080c1ac5705Bryan CantrillThen the document <code>xxxx.en.Z</code> will be treated as being a compressed
33093f5bcdc51014933497dd39374080c1ac5705Bryan CantrillEnglish document. Although the content language is reported to the client,
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrillthe browser is unlikely to use this information. The AddLanguage directive
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrillis more useful for content negotiation, where the server returns one
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrillfrom several documents based on the client's language preference.<p><hr>
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<!--%plaintext <?INDEX {\tt AddType} directive> -->
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<strong>Syntax:</strong> AddType <em>mime-type extension extension...</em><br>
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<Strong>Context:</strong> server config, virtual host, directory, .htaccess<br>
33093f5bcdc51014933497dd39374080c1ac5705Bryan CantrillThe AddType directive adds to the list of filename extensions which
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrillfilenames may end in for the specified content type. <em>Mime-enc</em>
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrillis the mime type to use for documents ending in <em>extension</em>.
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrillafter content-encoding and language extensions have been removed. Example:
33093f5bcdc51014933497dd39374080c1ac5705Bryan CantrillIt is recommended that new mime types be added using the AddType directive
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrillrather than changing the <A HREF="#typesconfig">TypesConfig</A> file.<p>
33093f5bcdc51014933497dd39374080c1ac5705Bryan CantrillNote that, unlike the NCSA httpd, this directive cannot be used to set the
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<strong>Syntax:</strong> <ForceType <em>media type</em>><br>
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<strong>Context:</strong> directory, .htaccess<br>
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<strong>Compatibility:</strong> ForceType is only available in Apache
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill1.1 and later.<p>
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<p>When placed into an <code>.htaccess</code> file or a
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<code><Directory></code> or <code><Location</code> section,
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrillthis directive forces all matching files to be served
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrillas the content type given by <em>media type</em>. For example, if you
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrillhad a directory full of GIF files, but did not want to label them all with
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill".gif", you might want to use:
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<p>Note that this will override any filename extensions that might
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrillmedia type.</p>
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<strong>Syntax:</strong> <SetHandler <em>handler-name</em>><br>
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<strong>Context:</strong> directory, .htaccess<br>
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<strong>Compatibility:</strong> SetHandler is only available in Apache
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill1.1 and later.<p>
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<p>When placed into an <code>.htaccess</code> file or a
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<code><Directory></code> or <code><Location</code> section,
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrillthis directive forces all matching files to be parsed through the
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrillgiven by <em>handler-name</em>. For example, if you had a
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrilldirectory you wanted to be parsed entirely as imagemap rule files,
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrillregardless of extension, you might put the following into an
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<code>.htaccess</code> file in that directory:
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill SetHandler imap-file
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<p>Another example: if you wanted to have the server display a status
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrillreport whenever a URL of <code>http://servername/status</code> was
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrillcalled, you might put the following into access.conf:
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill <Location /status>
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill SetHandler server-status
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill </Location>
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<A name="typesconfig"><h2>TypesConfig</h2></A>
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<!--%plaintext <?INDEX {\tt TypesConfig} directive> -->
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<strong>Syntax:</strong> TypesConfig <em>filename</em><br>
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<strong>Default:</strong> <code>TypesConfig conf/mime.types</code><br>
33093f5bcdc51014933497dd39374080c1ac5705Bryan CantrillThe TypesConfig directive sets the location of the mime types configuration
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<A HREF="#serverroot">ServerRoot</A>. This file sets the default list of
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrillmappings from filename extensions to content types; changing this file is not
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrillrecommended. Use the <A HREF="#addtype">AddType</A> directive instead. The
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrillfile contains lines in the format of the arguments to an AddType command:
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<blockquote><em>mime-type extension extension ...</em></blockquote>
33093f5bcdc51014933497dd39374080c1ac5705Bryan CantrillThe extensions are lower-cased. Blank lines, and lines beginning with a hash
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrillcharacter (`#') are ignored.<p>
33093f5bcdc51014933497dd39374080c1ac5705Bryan Cantrill<!--#include virtual="footer.html" -->