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