1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
4 <TITLE>Apache module mod_mime</TITLE>
7 <!-- Background white, links blue (unvisited), navy (visited), red (active) -->
15 <!--#include virtual="header.html" -->
16 <H1 ALIGN="CENTER">Module mod_mime</H1>
18 This module is contained in the <CODE>mod_mime.c</CODE> file, and is
19 compiled in by default. It provides for determining the types of files
24 This module is used to determine various bits of "meta information"
25 about documents. This information relates to the content of the
26 document and is returned to the browser or used in content-negotiation
27 within the server. In addition, a "handler" can be set for a document,
28 which determines how the document will be processed within the server.
32 The directives <A HREF="#addencoding">AddEncoding</A>, <A
33 HREF="#addhandler">AddHandler</A>, <A
34 HREF="#addlanguage">AddLanguage</A> and <A HREF="#addtype">AddType</A>
35 are all used to map file extensions onto the meta-information for that
36 file. Respectively they set the content-encoding, handler,
37 content-language and mime-type (content-type) of documents. The
38 directive <A HREF="#typesconfig">TypesConfig</A> is used to specify a
39 file which also maps extensions onto mime types. The directives <A
40 HREF="#forcetype">ForceType</A> and <A
41 HREF="#sethandler">SetHandler</A> are used to associated all the files
42 in a given location (e.g. a particular directory) onto a particular
47 Files can have more than one extension, and the order of the
48 extensions is normally irrelevant. For example, if the file
49 <CODE>welcome.html.fr</CODE> maps onto content type text/html and
50 language French then the file <CODE>welcome.fr.html</CODE> will map
51 onto exactly the same information. The only exception to this is if an
52 extension is given which Apache does not know how to handle. In this
53 case it will "forget" about any information it obtained from
54 extensions to the left of the unknown extension. So, for example, if
55 the extensions fr and html are mapped to the appropriate language and
56 type but extension xxx is not assigned to anything, then the file
57 <CODE>welcome.fr.xxx.html</CODE> will be associated with content-type
58 text/html but <EM>no</EM> language.
62 Note that changing the type or encoding of a file does not change the
63 value of the <CODE>Last-Modified</CODE> header. Thus, previously cached
64 copies may still be used by a client or proxy, with the previous headers.
68 Please note that changing a file's type or encoding does not change
69 the value of the <CODE>Last-Modified</CODE> header. Previously cached
70 copies may still be used by a client or proxy.
76 <LI><A HREF="#addencoding">AddEncoding</A>
77 <LI><A HREF="#addhandler">AddHandler</A>
78 <LI><A HREF="#addlanguage">AddLanguage</A>
79 <LI><A HREF="#addtype">AddType</A>
80 <LI><A HREF="#forcetype">ForceType</A>
81 <LI><A HREF="#sethandler">SetHandler</A>
82 <LI><A HREF="#typesconfig">TypesConfig</A>
87 <H2><A NAME="addencoding">AddEncoding</A></H2>
88 <!--%plaintext <?INDEX {\tt AddEncoding} directive> -->
90 HREF="directive-dict.html#Syntax"
92 ><STRONG>Syntax:</STRONG></A> AddEncoding <EM>mime-enc extension extension...</EM><BR>
94 HREF="directive-dict.html#Context"
96 ><STRONG>Context:</STRONG></A> server config, virtual host, directory, .htaccess<BR>
98 HREF="directive-dict.html#Override"
100 ><STRONG>Override:</STRONG></A> FileInfo<BR>
102 HREF="directive-dict.html#Status"
104 ><STRONG>Status:</STRONG></A> Base<BR>
106 HREF="directive-dict.html#Module"
108 ><STRONG>Module:</STRONG></A> mod_mime<P>
110 The AddEncoding directive adds to the list of filename extensions which
111 filenames may end in for the specified encoding type. <EM>Mime-enc</EM>
112 is the mime encoding to use for documents ending in <EM>extension</EM>.
115 AddEncoding x-gzip gz<BR>
116 AddEncoding x-compress Z
119 This will cause files ending in .gz to be marked as encoded using the x-gzip
120 encoding, and .Z files to be marked as encoded with x-compress.<P>
122 Old clients expect <CODE>x-gzip</CODE> and <CODE>x-compress</CODE>,
123 however the standard dictates that they're equivalent to <CODE>gzip</CODE>
124 and <CODE>compress</CODE> respectively. Apache does content encoding
125 comparisons by ignoring any leading <CODE>x-</CODE>. When responding
126 with an encoding Apache will use whatever form (i.e. <CODE>x-foo</CODE>
127 or <CODE>foo</CODE>) the client requested. If the client didn't
128 specifically request a particular form Apache will use the form given by
129 the <CODE>AddEncoding</CODE> directive. To make this long story short,
130 you should always use <CODE>x-gzip</CODE> and <CODE>x-compress</CODE>
131 for these two specific encodings. More recent encodings, such as
132 <CODE>deflate</CODE> should be specified without the <CODE>x-</CODE>.
136 <H2><A NAME="addhandler">AddHandler</A></H2>
139 HREF="directive-dict.html#Syntax"
141 ><STRONG>Syntax:</STRONG></A> AddHandler <EM>handler-name extension extension...</EM><BR>
143 HREF="directive-dict.html#Context"
145 ><STRONG>Context:</STRONG></A> server config, virtual host, directory, .htaccess<BR>
147 HREF="directive-dict.html#Status"
149 ><STRONG>Status:</STRONG></A> Base<BR>
151 HREF="directive-dict.html#Module"
153 ><STRONG>Module:</STRONG></A> mod_mime<BR>
155 HREF="directive-dict.html#Compatibility"
157 ><STRONG>Compatibility:</STRONG></A> AddHandler is only available in Apache
160 <P>AddHandler maps the filename extensions <EM>extension</EM> to the
161 <A HREF="../handler.html">handler</A>
162 <EM>handler-name</EM>. For example, to activate CGI scripts
163 with the file extension "<CODE>.cgi</CODE>", you might use:
165 AddHandler cgi-script cgi
168 <P>Once that has been put into your srm.conf or httpd.conf file, any
169 file ending with "<CODE>.cgi</CODE>" will be treated as a CGI
173 <H2><A NAME="addlanguage">AddLanguage</A></H2>
174 <!--%plaintext <?INDEX {\tt AddLanguage} directive> -->
176 HREF="directive-dict.html#Syntax"
178 ><STRONG>Syntax:</STRONG></A> AddLanguage <EM>mime-lang extension extension...</EM><BR>
180 HREF="directive-dict.html#Context"
182 ><STRONG>Context:</STRONG></A> server config, virtual host, directory, .htaccess<BR>
184 HREF="directive-dict.html#Override"
186 ><STRONG>Override:</STRONG></A> FileInfo<BR>
188 HREF="directive-dict.html#Status"
190 ><STRONG>Status:</STRONG></A> Base<BR>
192 HREF="directive-dict.html#Module"
194 ><STRONG>Module:</STRONG></A> mod_mime<P>
196 The AddLanguage directive adds to the list of filename extensions which
197 filenames may end in for the specified content language. <EM>Mime-lang</EM>
198 is the mime language of files with names ending <EM>extension</EM>,
199 after any content encoding extensions have been removed. Example:
201 AddEncoding x-compress Z<BR>
202 AddLanguage en .en<BR>
203 AddLanguage fr .fr<BR>
206 Then the document <CODE>xxxx.en.Z</CODE> will be treated as being a compressed
207 English document. Although the content language is reported to the client,
208 the browser is unlikely to use this information. The AddLanguage directive
209 is more useful for content negotiation, where the server returns one
210 from several documents based on the client's language preference.<P><HR>
212 <H2><A NAME="addtype">AddType</A></H2>
213 <!--%plaintext <?INDEX {\tt AddType} directive> -->
215 HREF="directive-dict.html#Syntax"
217 ><STRONG>Syntax:</STRONG></A> AddType <EM>mime-type extension extension...</EM><BR>
219 HREF="directive-dict.html#Context"
221 ><STRONG>Context:</STRONG></A> server config, virtual host, directory, .htaccess<BR>
223 HREF="directive-dict.html#Override"
225 ><STRONG>Override:</STRONG></A> FileInfo<BR>
227 HREF="directive-dict.html#Status"
229 ><STRONG>Status:</STRONG></A> Base<BR>
231 HREF="directive-dict.html#Module"
233 ><STRONG>Module:</STRONG></A> mod_mime<P>
235 The AddType directive adds to the list of filename extensions which
236 filenames may end in for the specified content type. <EM>Mime-enc</EM>
237 is the mime type to use for documents ending in <EM>extension</EM>.
238 after content-encoding and language extensions have been removed. Example:
240 AddType image/gif GIF
242 It is recommended that new mime types be added using the AddType directive
243 rather than changing the <A HREF="#typesconfig">TypesConfig</A> file.<P>
244 Note that, unlike the NCSA httpd, this directive cannot be used to set the
245 type of particular files.<P><HR>
247 <H2><A NAME="forcetype">ForceType</A></H2>
250 HREF="directive-dict.html#Syntax"
252 ><STRONG>Syntax:</STRONG></A> ForceType <EM>media type</EM><BR>
254 HREF="directive-dict.html#Context"
256 ><STRONG>Context:</STRONG></A> directory, .htaccess<BR>
258 HREF="directive-dict.html#Status"
260 ><STRONG>Status:</STRONG></A> Base<BR>
262 HREF="directive-dict.html#Module"
264 ><STRONG>Module:</STRONG></A> mod_mime<BR>
266 HREF="directive-dict.html#Compatibility"
268 ><STRONG>Compatibility:</STRONG></A> ForceType is only available in Apache
271 <P>When placed into an <CODE>.htaccess</CODE> file or a
272 <CODE><Directory></CODE> or <CODE><Location></CODE> section,
273 this directive forces all matching files to be served
274 as the content type given by <EM>media type</EM>. For example, if you
275 had a directory full of GIF files, but did not want to label them all with
276 ".gif", you might want to use:
280 <P>Note that this will override any filename extensions that might determine
281 the media type.</P><HR>
283 <H2><A NAME="sethandler">SetHandler</A></H2>
286 HREF="directive-dict.html#Syntax"
288 ><STRONG>Syntax:</STRONG></A> SetHandler <EM>handler-name</EM><BR>
290 HREF="directive-dict.html#Context"
292 ><STRONG>Context:</STRONG></A> directory, .htaccess<BR>
294 HREF="directive-dict.html#Status"
296 ><STRONG>Status:</STRONG></A> Base<BR>
298 HREF="directive-dict.html#Module"
300 ><STRONG>Module:</STRONG></A> mod_mime<BR>
302 HREF="directive-dict.html#Compatibility"
304 ><STRONG>Compatibility:</STRONG></A> SetHandler is only available in Apache
307 <P>When placed into an <CODE>.htaccess</CODE> file or a
308 <CODE><Directory></CODE> or <CODE><Location></CODE> section,
309 this directive forces all matching files to be parsed through the
310 <A HREF="../handler.html">handler</A>
311 given by <EM>handler-name</EM>. For example, if you had a
312 directory you wanted to be parsed entirely as imagemap rule files,
313 regardless of extension, you might put the following into an
314 <CODE>.htaccess</CODE> file in that directory:
319 <P>Another example: if you wanted to have the server display a status
320 report whenever a URL of <CODE>http://servername/status</CODE> was
321 called, you might put the following into access.conf:
323 <Location /status>
324 SetHandler server-status
329 <H2><A NAME="typesconfig">TypesConfig</A></H2>
330 <!--%plaintext <?INDEX {\tt TypesConfig} directive> -->
332 HREF="directive-dict.html#Syntax"
334 ><STRONG>Syntax:</STRONG></A> TypesConfig <EM>filename</EM><BR>
336 HREF="directive-dict.html#Default"
338 ><STRONG>Default:</STRONG></A> <CODE>TypesConfig conf/mime.types</CODE><BR>
340 HREF="directive-dict.html#Context"
342 ><STRONG>Context:</STRONG></A> server config<BR>
344 HREF="directive-dict.html#Status"
346 ><STRONG>Status:</STRONG></A> Base<BR>
348 HREF="directive-dict.html#Module"
350 ><STRONG>Module:</STRONG></A> mod_mime<P>
352 The TypesConfig directive sets the location of the mime types configuration
353 file. <EM>Filename</EM> is relative to the
354 <A HREF="core.html#serverroot">ServerRoot</A>. This file sets the default list of
355 mappings from filename extensions to content types; changing this file is not
356 recommended. Use the <A HREF="#addtype">AddType</A> directive instead. The
357 file contains lines in the format of the arguments to an AddType command:
358 <BLOCKQUOTE><EM>mime-type extension extension ...</EM></BLOCKQUOTE>
359 The extensions are lower-cased. Blank lines, and lines beginning with a hash
360 character (`#') are ignored.<P>
362 <!--#include virtual="footer.html" -->