mod_mime.html revision 668aa75aff0fa0f7b3bedb0ac0a67189885dc053
1516N/A<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
539N/A<HTML>
539N/A<HEAD>
539N/A<TITLE>Apache module mod_mime</TITLE>
539N/A</HEAD>
539N/A
539N/A<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
539N/A<BODY
539N/A BGCOLOR="#FFFFFF"
539N/A TEXT="#000000"
539N/A LINK="#0000FF"
539N/A VLINK="#000080"
539N/A ALINK="#FF0000"
539N/A>
539N/A<!--#include virtual="header.html" -->
539N/A<H1 ALIGN="CENTER">Module mod_mime</H1>
539N/A
539N/AThis module is contained in the <CODE>mod_mime.c</CODE> file, and is
539N/Acompiled in by default. It provides for determining the types of files
539N/Afrom the filename.
539N/A
539N/A<H2>Summary</H2>
926N/A
926N/AThis module is used to determine various bits of "meta information"
539N/Aabout documents. This information relates to the content of the
926N/Adocument and is returned to the browser or used in content-negotiation
539N/Awithin the server. In addition, a "handler" can be set for a document,
539N/Awhich determines how the document will be processed within the server.
539N/A
539N/A<P>
539N/A
732N/AThe directives <A HREF="#addencoding">AddEncoding</A>, <A
539N/AHREF="#addhandler">AddHandler</A>, <A
539N/AHREF="#addlanguage">AddLanguage</A> and <A HREF="#addtype">AddType</A>
539N/Aare all used to map file extensions onto the meta-information for that
539N/Afile. Respectively they set the content-encoding, handler,
539N/Acontent-language and mime-type (content-type) of documents. The
539N/Adirective <A HREF="#typesconfig">TypesConfig</A> is used to specify a
539N/Afile which also maps extensions onto mime types. The directives <A
539N/AHREF="#forcetype">ForceType</A> and <A
539N/AHREF="#sethandler">SetHandler</A> are used to associated all the files
539N/Ain a given location (e.g. a particular directory) onto a particular
539N/Amime type or handler.
539N/A
539N/A<P>
716N/A
716N/AFiles can have more than one extension, and the order of the
716N/Aextensions is normally irrelevant. For example, if the file
716N/A<CODE>welcome.html.fr</CODE> maps onto content type text/html and
716N/Alanguage French then the file <CODE>welcome.fr.html</CODE> will map
716N/Aonto exactly the same information. The only exception to this is if an
716N/Aextension is given which Apache does not know how to handle. In this
716N/Acase it will "forget" about any information it obtained from
716N/Aextensions to the left of the unknown extension. So, for example, if
539N/Athe extensions fr and html are mapped to the appropriate language and
1431N/Atype but extension xxx is not assigned to anything, then the file
539N/A<CODE>welcome.fr.xxx.html</CODE> will be associated with content-type
539N/Atext/html but <EM>no</EM> language.
539N/A
539N/A<P>
539N/A
539N/ANote that changing the type or encoding of a file does not change the
539N/Avalue of the <CODE>Last-Modified</CODE> header. Thus, previously cached
539N/Acopies may still be used by a client or proxy, with the previous headers.
539N/A
1431N/A<P>
1431N/A
539N/APlease note that changing a file's type or encoding does not change
1431N/Athe value of the <CODE>Last-Modified</CODE> header. Previously cached
539N/Acopies may still be used by a client or proxy.
1431N/A
539N/A<P>
539N/A
539N/A<H2> Directives</H2>
539N/A<UL>
539N/A<LI><A HREF="#addencoding">AddEncoding</A>
539N/A<LI><A HREF="#addhandler">AddHandler</A>
539N/A<LI><A HREF="#addlanguage">AddLanguage</A>
539N/A<LI><A HREF="#addtype">AddType</A>
539N/A<LI><A HREF="#forcetype">ForceType</A>
539N/A<LI><A HREF="#sethandler">SetHandler</A>
539N/A<LI><A HREF="#typesconfig">TypesConfig</A>
539N/A</UL>
539N/A<HR>
539N/A
539N/A
539N/A<H2><A name="addencoding">AddEncoding</A></H2>
539N/A<!--%plaintext &lt;?INDEX {\tt AddEncoding} directive&gt; -->
539N/A<A
539N/A HREF="directive-dict.html#Syntax"
539N/A REL="Help"
1505N/A><STRONG>Syntax:</STRONG></A> AddEncoding <EM>mime-enc extension extension...</EM><BR>
1505N/A<A
1505N/A HREF="directive-dict.html#Context"
1505N/A REL="Help"
1505N/A><STRONG>Context:</STRONG></A> server config, virtual host, directory, .htaccess<BR>
1505N/A<A
1505N/A HREF="directive-dict.html#Override"
1505N/A REL="Help"
1505N/A><STRONG>Override:</STRONG></A> FileInfo<BR>
539N/A<A
539N/A HREF="directive-dict.html#Status"
539N/A REL="Help"
539N/A><STRONG>Status:</STRONG></A> Base<BR>
539N/A<A
539N/A HREF="directive-dict.html#Module"
926N/A REL="Help"
926N/A><STRONG>Module:</STRONG></A> mod_mime<P>
926N/A
926N/AThe AddEncoding directive adds to the list of filename extensions which
539N/Afilenames may end in for the specified encoding type. <EM>Mime-enc</EM>
539N/Ais the mime encoding to use for documents ending in <EM>extension</EM>.
539N/AExample:
1505N/A<BLOCKQUOTE><CODE>
1505N/AAddEncoding x-gzip gz<BR>
539N/AAddEncoding x-compress Z
539N/A</CODE></BLOCKQUOTE>
539N/A
539N/AThis will cause files ending in .gz to be marked as encoded using the x-gzip
539N/Aencoding, and .Z files to be marked as encoded with x-compress.<P>
539N/A
539N/AOld clients expect <code>x-gzip</code> and <code>x-compress</code>,
539N/Ahowever the standard dictates that they're equivalent to <code>gzip</code>
539N/Aand <code>compress</code> respectively. Apache does content encoding
565N/Acomparisons by ignoring any leading <code>x-</code>. When responding
565N/Awith an encoding Apache will use whatever form (i.e. <code>x-foo</code>
565N/Aor <code>foo</code>) the client requested. If the client didn't
539N/Aspecifically request a particular form Apache will use the form given by
539N/Athe <code>AddEncoding</code> directive. To make this long story short,
539N/Ayou should always use <code>x-gzip</code> and <code>x-compress</code>
539N/Afor these two specific encodings. More recent encodings, such as
1505N/A<code>deflate</code> should be specified without the <code>x-</code>.
539N/A
565N/A<P><HR>
565N/A
565N/A<H2><A name="addhandler">AddHandler</A></H2>
539N/A
539N/A<A
539N/A HREF="directive-dict.html#Syntax"
539N/A REL="Help"
539N/A><STRONG>Syntax:</STRONG></A> AddHandler <EM>handler-name extension extension...</EM><BR>
539N/A<A
539N/A HREF="directive-dict.html#Context"
539N/A REL="Help"
539N/A><STRONG>Context:</STRONG></A> server config, virtual host, directory, .htaccess<BR>
539N/A<A
539N/A HREF="directive-dict.html#Status"
539N/A REL="Help"
996N/A><STRONG>Status:</STRONG></A> Base<BR>
716N/A<A
716N/A HREF="directive-dict.html#Module"
716N/A REL="Help"
716N/A><STRONG>Module:</STRONG></A> mod_mime<BR>
716N/A<A
716N/A HREF="directive-dict.html#Compatibility"
716N/A REL="Help"
716N/A><STRONG>Compatibility:</STRONG></A> AddHandler is only available in Apache
716N/A1.1 and later<P>
716N/A
716N/A<P>AddHandler maps the filename extensions <EM>extension</EM> to the
716N/A<A HREF="/handler.html">handler</A>
716N/A<EM>handler-name</EM>. For example, to activate CGI scripts
716N/Awith the file extension "<CODE>.cgi</CODE>", you might use:
716N/A<PRE>
996N/A AddHandler cgi-script cgi
1102N/A</PRE>
716N/A
732N/A<P>Once that has been put into your srm.conf or httpd.conf file, any
716N/Afile ending with "<CODE>.cgi</CODE>" will be treated as a CGI
716N/Aprogram.</P>
716N/A<HR>
716N/A
716N/A<H2><A name="addlanguage">AddLanguage</A></H2>
996N/A<!--%plaintext &lt;?INDEX {\tt AddLanguage} directive&gt; -->
716N/A<A
716N/A HREF="directive-dict.html#Syntax"
716N/A REL="Help"
996N/A><STRONG>Syntax:</STRONG></A> AddLanguage <EM>mime-lang extension extension...</EM><BR>
716N/A<A
716N/A HREF="directive-dict.html#Context"
716N/A REL="Help"
716N/A><STRONG>Context:</STRONG></A> server config, virtual host, directory, .htaccess<BR>
716N/A<A
716N/A HREF="directive-dict.html#Override"
716N/A REL="Help"
716N/A><STRONG>Override:</STRONG></A> FileInfo<BR>
716N/A<A
716N/A HREF="directive-dict.html#Status"
996N/A REL="Help"
1102N/A><STRONG>Status:</STRONG></A> Base<BR>
716N/A<A
732N/A HREF="directive-dict.html#Module"
732N/A REL="Help"
732N/A><STRONG>Module:</STRONG></A> mod_mime<P>
732N/A
732N/AThe AddLanguage directive adds to the list of filename extensions which
732N/Afilenames may end in for the specified content language. <EM>Mime-lang</EM>
732N/Ais the mime language of files with names ending <EM>extension</EM>,
732N/Aafter any content encoding extensions have been removed. Example:
732N/A<BLOCKQUOTE><CODE>
732N/AAddEncoding x-compress Z<BR>
732N/AAddLanguage en .en<BR>
732N/AAddLanguage fr .fr<BR>
732N/A</CODE></BLOCKQUOTE>
732N/A
732N/AThen the document <CODE>xxxx.en.Z</CODE> will be treated as being a compressed
732N/AEnglish document. Although the content language is reported to the client,
732N/Athe browser is unlikely to use this information. The AddLanguage directive
732N/Ais more useful for content negotiation, where the server returns one
732N/Afrom several documents based on the client's language preference.<P><HR>
732N/A
732N/A<H2><A name="addtype">AddType</A></H2>
732N/A<!--%plaintext &lt;?INDEX {\tt AddType} directive&gt; -->
732N/A<A
732N/A HREF="directive-dict.html#Syntax"
732N/A REL="Help"
732N/A><STRONG>Syntax:</STRONG></A> AddType <EM>mime-type extension extension...</EM><BR>
732N/A<A
732N/A HREF="directive-dict.html#Context"
732N/A REL="Help"
732N/A><STRONG>Context:</STRONG></A> server config, virtual host, directory, .htaccess<BR>
732N/A<A
732N/A HREF="directive-dict.html#Override"
1102N/A REL="Help"
1102N/A><STRONG>Override:</STRONG></A> FileInfo<BR>
1102N/A<A
1102N/A HREF="directive-dict.html#Status"
1102N/A REL="Help"
1102N/A><STRONG>Status:</STRONG></A> Base<BR>
1102N/A<A
1102N/A HREF="directive-dict.html#Module"
1102N/A REL="Help"
1102N/A><STRONG>Module:</STRONG></A> mod_mime<P>
1102N/A
1102N/AThe AddType directive adds to the list of filename extensions which
1102N/Afilenames may end in for the specified content type. <EM>Mime-enc</EM>
1102N/Ais the mime type to use for documents ending in <EM>extension</EM>.
1102N/Aafter content-encoding and language extensions have been removed. Example:
1102N/A<BLOCKQUOTE><CODE>
1102N/AAddType image/gif GIF
1102N/A</CODE></BLOCKQUOTE>
1102N/AIt is recommended that new mime types be added using the AddType directive
1102N/Arather than changing the <A HREF="#typesconfig">TypesConfig</A> file.<P>
1102N/ANote that, unlike the NCSA httpd, this directive cannot be used to set the
1102N/Atype of particular files.<P><HR>
1102N/A
1102N/A<H2><A name="forcetype">ForceType</A></H2>
1102N/A
1102N/A<A
1102N/A HREF="directive-dict.html#Syntax"
1102N/A REL="Help"
1102N/A><STRONG>Syntax:</STRONG></A> ForceType <EM>media type</EM><BR>
1102N/A<A
1102N/A HREF="directive-dict.html#Context"
1102N/A REL="Help"
1102N/A><STRONG>Context:</STRONG></A> directory, .htaccess<BR>
1102N/A<A
1102N/A HREF="directive-dict.html#Status"
1102N/A REL="Help"
1102N/A><STRONG>Status:</STRONG></A> Base<BR>
1102N/A<A
1102N/A HREF="directive-dict.html#Module"
1102N/A REL="Help"
1102N/A><STRONG>Module:</STRONG></A> mod_mime<BR>
1102N/A<A
1102N/A HREF="directive-dict.html#Compatibility"
1102N/A REL="Help"
1102N/A><STRONG>Compatibility:</STRONG></A> ForceType is only available in Apache
1102N/A1.1 and later.<P>
1102N/A
1102N/A<P>When placed into an <CODE>.htaccess</CODE> file or a
1102N/A<CODE>&lt;Directory&gt;</CODE> or <CODE>&lt;Location&gt;</CODE> section,
1102N/Athis directive forces all matching files to be served
1102N/Aas the content type given by <EM>media type</EM>. For example, if you
1102N/Ahad a directory full of GIF files, but did not want to label them all with
1102N/A".gif", you might want to use:
1102N/A<PRE>
1102N/A ForceType image/gif
1102N/A</PRE>
1102N/A<P>Note that this will override any filename extensions that might
1102N/Amedia type.</P>
1102N/A
1102N/A<H2><A name="sethandler">SetHandler</A></H2>
539N/A
539N/A<A
539N/A HREF="directive-dict.html#Syntax"
REL="Help"
><STRONG>Syntax:</STRONG></A> SetHandler <EM>handler-name</EM><BR>
<A
HREF="directive-dict.html#Context"
REL="Help"
><STRONG>Context:</STRONG></A> directory, .htaccess<BR>
<A
HREF="directive-dict.html#Status"
REL="Help"
><STRONG>Status:</STRONG></A> Base<BR>
<A
HREF="directive-dict.html#Module"
REL="Help"
><STRONG>Module:</STRONG></A> mod_mime<BR>
<A
HREF="directive-dict.html#Compatibility"
REL="Help"
><STRONG>Compatibility:</STRONG></A> 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&gt;</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>
<HR>
<H2><A name="typesconfig">TypesConfig</A></H2>
<!--%plaintext &lt;?INDEX {\tt TypesConfig} directive&gt; -->
<A
HREF="directive-dict.html#Syntax"
REL="Help"
><STRONG>Syntax:</STRONG></A> TypesConfig <EM>filename</EM><BR>
<A
HREF="directive-dict.html#Default"
REL="Help"
><STRONG>Default:</STRONG></A> <CODE>TypesConfig conf/mime.types</CODE><BR>
<A
HREF="directive-dict.html#Context"
REL="Help"
><STRONG>Context:</STRONG></A> server config<BR>
<A
HREF="directive-dict.html#Status"
REL="Help"
><STRONG>Status:</STRONG></A> Base<BR>
<A
HREF="directive-dict.html#Module"
REL="Help"
><STRONG>Module:</STRONG></A> mod_mime<P>
The TypesConfig directive sets the location of the mime types configuration
file. <EM>Filename</EM> is relative to the
<A HREF="core.html#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>
<!--#include virtual="footer.html" -->
</BODY>
</HTML>