mod_mime.html revision 4e59fdbc3e0d0c17a28469c9efbc0a071622d5ec
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster BGCOLOR="#FFFFFF"
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster TEXT="#000000"
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster LINK="#0000FF"
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster VLINK="#000080"
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster ALINK="#FF0000"
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster<!--#include virtual="header.html" -->
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster<p>This module provides for determining the types of files
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterfrom the filename and for association of handlers with files.</p>
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan FosterHREF="module-dict.html#SourceFile"
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan FosterHREF="module-dict.html#ModuleIdentifier"
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster><STRONG>Module Identifier:</STRONG></A> mime_module
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan FosterThis module is used to determine various bits of "meta information"
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterabout documents. This information relates to the content of the
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterdocument and is returned to the browser or used in content-negotiation
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterwithin the server. In addition, a "handler" can be set for a document,
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterwhich determines how the document will be processed within the server.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan FosterThe directives <a href="#addcharset">AddCharset</a>,
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster<A HREF="#addencoding">AddEncoding</A>, <A HREF="#addhandler">AddHandler</A>,
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster<A HREF="#addlanguage">AddLanguage</A> and <A HREF="#addtype">AddType</A>
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterare all used to map file extensions onto the meta-information for that
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterfile. Respectively they set the character set, content-encoding, handler,
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fostercontent-language, and MIME-type (content-type) of documents. The
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterdirective <A HREF="#typesconfig">TypesConfig</A> is used to specify a
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterfile which also maps extensions onto MIME types. The directives <A
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan FosterHREF="#sethandler">SetHandler</A> are used to associated all the files
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterin a given location (<EM>e.g.</EM>, a particular directory) onto a particular
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan FosterMIME type or handler.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan FosterNote that changing the type or encoding of a file does not change the
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fostervalue of the <CODE>Last-Modified</CODE> header. Thus, previously cached
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fostercopies may still be used by a client or proxy, with the previous headers.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster<LI><A HREF="#defaultlanguage">DefaultLanguage</A>
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterhref="mod_mime_magic.html#mimemagicfile">MimeMagicFile</a>.</p>
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster<H2><A NAME="multipleext">Files with Multiple Extensions</A></H2>
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan FosterFiles can have more than one extension, and the order of the
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterextensions is <EM>normally</EM> irrelevant. For example, if the file
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster<CODE>welcome.html.fr</CODE> maps onto content type text/html and
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterlanguage French then the file <CODE>welcome.fr.html</CODE> will map
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosteronto exactly the same information. The only exception to this is if an
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterextension is given which Apache does not know how to handle. In this
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fostercase it will "forget" about any information it obtained from
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterextensions to the left of the unknown extension. So, for example, if
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterthe extensions fr and html are mapped to the appropriate language and
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fostertype but extension xxx is not assigned to anything, then the file
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster<CODE>welcome.fr.xxx.html</CODE> will be associated with content-type
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan FosterIf more than one extension is given which maps onto the same type of
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fostermeta-information, then the one to the right will be used. For example,
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterif ".gif" maps to the MIME-type image/gif and ".html" maps to the
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan FosterMIME-type text/html, then the file <CODE>welcome.gif.html</CODE> will
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan FosterCare should be taken when a file with multiple extensions gets
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterassociated with both a MIME-type and a handler. This will usually
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterresult in the request being by the module associated with the
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterhandler. For example, if the <CODE>.imap</CODE> extension is mapped to
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterthe handler "imap-file" (from mod_imap) and the <CODE>.html</CODE>
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterextension is mapped to the MIME-type "text/html", then the file
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster<CODE>world.imap.html</CODE> will be associated with both the
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster"imap-file" handler and "text/html" MIME-type. When it is processed,
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterthe "imap-file" handler will be used, and so it will be treated as a
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fostermod_imap imagemap file.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster<H2><A NAME="addcharset">AddCharset</A> directive</H2>
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster><STRONG>Syntax:</STRONG></A> AddCharset <i>charset extension
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster<A HREF="directive-dict.html#Context" REL="Help"
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster><STRONG>Context:</STRONG></A> server config, virtual host, directory, .htaccess<BR>
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan FosterThe AddCharset directive maps the given filename extensions to the
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterspecified content charset. <i>charset</i> is the MIME charset
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterparameter of filenames containing <i>extension</i>. This mapping is
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosteradded to any already in force, overriding any mappings that already
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster AddLanguage ja .ja
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster AddCharset EUC-JP .euc
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster AddCharset ISO-2022-JP .jis
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster AddCharset SHIFT_JIS .sjis
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan FosterThen the document <CODE>xxxx.ja.jis</CODE> will be treated as being a
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan FosterJapanese document whose charset is ISO-2022-JP (as will the document
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster<CODE>xxxx.jis.ja</CODE>). The AddCharset directive is useful for both
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterto inform the client about the character encoding of the document so
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterthat the document can be interpreted and displayed appropriately, and
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterfor <A HREF="/content-negotiation.html">content negotiation</A>, where
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterthe server returns one from several documents based on the client's
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fostercharset preference.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster<STRONG>See also</STRONG>: <A HREF="mod_negotiation.html">mod_negotiation</A>
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster<H2><A NAME="addencoding">AddEncoding</A> directive</H2>
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster<!--%plaintext <?INDEX {\tt AddEncoding} directive> -->
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster><STRONG>Syntax:</STRONG></A> AddEncoding <EM>MIME-enc extension extension...</EM><BR>
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster><STRONG>Context:</STRONG></A> server config, virtual host, directory, .htaccess<BR>
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan FosterThe AddEncoding directive maps the given filename extensions to the
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterspecified encoding type. <EM>MIME-enc</EM> is the MIME encoding to use
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterfor documents containing the <EM>extension</EM>. This mapping is added
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterto any already in force, overriding any mappings that already exist
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster<BLOCKQUOTE><CODE> AddEncoding x-gzip gz<BR> AddEncoding x-compress Z
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan FosterThis will cause filenames containing the .gz extension to be marked as
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterencoded using the x-gzip encoding, and filenames containing the .Z
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterextension to be marked as encoded with x-compress.<P>
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan FosterOld clients expect <CODE>x-gzip</CODE> and <CODE>x-compress</CODE>,
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterhowever the standard dictates that they're equivalent to <CODE>gzip</CODE>
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterand <CODE>compress</CODE> respectively. Apache does content encoding
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fostercomparisons by ignoring any leading <CODE>x-</CODE>. When responding
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterwith an encoding Apache will use whatever form (<EM>i.e.</EM>, <CODE>x-foo</CODE>
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosteror <CODE>foo</CODE>) the client requested. If the client didn't
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterspecifically request a particular form Apache will use the form given by
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterthe <CODE>AddEncoding</CODE> directive. To make this long story short,
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosteryou should always use <CODE>x-gzip</CODE> and <CODE>x-compress</CODE>
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterfor these two specific encodings. More recent encodings, such as
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster<CODE>deflate</CODE> should be specified without the <CODE>x-</CODE>.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster<STRONG>See also</STRONG>: <A HREF="#multipleext">Files with
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fostermultiple extensions</A>
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster<H2><A NAME="addhandler">AddHandler</A> directive</H2>
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster><STRONG>Syntax:</STRONG></A> AddHandler <EM>handler-name extension extension...</EM><BR>
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster><STRONG>Context:</STRONG></A> server config, virtual host, directory, .htaccess<BR>
HREF="directive-dict.html#Syntax"
HREF="directive-dict.html#Context"
HREF="directive-dict.html#Override"
HREF="directive-dict.html#Status"
HREF="directive-dict.html#Module"
HREF="directive-dict.html#Syntax"
HREF="directive-dict.html#Context"
HREF="directive-dict.html#Override"
HREF="directive-dict.html#Status"
HREF="directive-dict.html#Module"
HREF="directive-dict.html#Syntax"
HREF="directive-dict.html#Context"
HREF="directive-dict.html#Override"
HREF="directive-dict.html#Status"
HREF="directive-dict.html#Module"
HREF="directive-dict.html#Syntax"
HREF="directive-dict.html#Context"
HREF="directive-dict.html#Status"
HREF="directive-dict.html#Module"
HREF="directive-dict.html#Syntax"
HREF="directive-dict.html#Context"
HREF="directive-dict.html#Status"
HREF="directive-dict.html#Module"
HREF="directive-dict.html#Syntax"
HREF="directive-dict.html#Context"
HREF="directive-dict.html#Status"
HREF="directive-dict.html#Module"
called, you might put the following into access.conf:
HREF="directive-dict.html#Syntax"
HREF="directive-dict.html#Default"
HREF="directive-dict.html#Context"
HREF="directive-dict.html#Status"
HREF="directive-dict.html#Module"
<!--#include virtual="footer.html" -->