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#Override"
149 ><STRONG>Override:</STRONG></A> FileInfo<BR>
151 HREF="directive-dict.html#Status"
153 ><STRONG>Status:</STRONG></A> Base<BR>
155 HREF="directive-dict.html#Module"
157 ><STRONG>Module:</STRONG></A> mod_mime<BR>
159 HREF="directive-dict.html#Compatibility"
161 ><STRONG>Compatibility:</STRONG></A> AddHandler is only available in Apache
164 <P>AddHandler maps the filename extensions <EM>extension</EM> to the
165 <A HREF="../handler.html">handler</A>
166 <EM>handler-name</EM>. For example, to activate CGI scripts
167 with the file extension "<CODE>.cgi</CODE>", you might use:
169 AddHandler cgi-script cgi
172 <P>Once that has been put into your srm.conf or httpd.conf file, any
173 file ending with "<CODE>.cgi</CODE>" will be treated as a CGI
177 <H2><A NAME="addlanguage">AddLanguage</A></H2>
178 <!--%plaintext <?INDEX {\tt AddLanguage} directive> -->
180 HREF="directive-dict.html#Syntax"
182 ><STRONG>Syntax:</STRONG></A> AddLanguage <EM>MIME-lang extension extension...</EM><BR>
184 HREF="directive-dict.html#Context"
186 ><STRONG>Context:</STRONG></A> server config, virtual host, directory, .htaccess<BR>
188 HREF="directive-dict.html#Override"
190 ><STRONG>Override:</STRONG></A> FileInfo<BR>
192 HREF="directive-dict.html#Status"
194 ><STRONG>Status:</STRONG></A> Base<BR>
196 HREF="directive-dict.html#Module"
198 ><STRONG>Module:</STRONG></A> mod_mime<P>
200 The AddLanguage directive adds to the list of filename extensions which
201 filenames may end in for the specified content language. <EM>Mime-lang</EM>
202 is the mime language of files with names ending <EM>extension</EM>,
203 after any content encoding extensions have been removed. Example:
205 AddEncoding x-compress Z<BR>
206 AddLanguage en .en<BR>
207 AddLanguage fr .fr<BR>
210 Then the document <CODE>xxxx.en.Z</CODE> will be treated as being a compressed
211 English document. Although the content language is reported to the client,
212 the browser is unlikely to use this information. The AddLanguage directive
213 is more useful for content negotiation, where the server returns one
214 from several documents based on the client's language preference.<P><HR>
216 <H2><A NAME="addtype">AddType</A></H2>
217 <!--%plaintext <?INDEX {\tt AddType} directive> -->
219 HREF="directive-dict.html#Syntax"
221 ><STRONG>Syntax:</STRONG></A> AddType <EM>MIME-type extension extension...</EM><BR>
223 HREF="directive-dict.html#Context"
225 ><STRONG>Context:</STRONG></A> server config, virtual host, directory, .htaccess<BR>
227 HREF="directive-dict.html#Override"
229 ><STRONG>Override:</STRONG></A> FileInfo<BR>
231 HREF="directive-dict.html#Status"
233 ><STRONG>Status:</STRONG></A> Base<BR>
235 HREF="directive-dict.html#Module"
237 ><STRONG>Module:</STRONG></A> mod_mime<P>
239 The AddType directive adds to the list of filename extensions which
240 filenames may end in for the specified content type. <EM>Mime-enc</EM>
241 is the mime type to use for documents ending in <EM>extension</EM>.
242 after content-encoding and language extensions have been removed. Example:
244 AddType image/gif GIF
246 It is recommended that new mime types be added using the AddType directive
247 rather than changing the <A HREF="#typesconfig">TypesConfig</A> file.<P>
248 Note that, unlike the NCSA httpd, this directive cannot be used to set the
249 type of particular files.<P><HR>
251 <H2><A NAME="forcetype">ForceType</A></H2>
254 HREF="directive-dict.html#Syntax"
256 ><STRONG>Syntax:</STRONG></A> ForceType <EM>media type</EM><BR>
258 HREF="directive-dict.html#Context"
260 ><STRONG>Context:</STRONG></A> directory, .htaccess<BR>
262 HREF="directive-dict.html#Status"
264 ><STRONG>Status:</STRONG></A> Base<BR>
266 HREF="directive-dict.html#Module"
268 ><STRONG>Module:</STRONG></A> mod_mime<BR>
270 HREF="directive-dict.html#Compatibility"
272 ><STRONG>Compatibility:</STRONG></A> ForceType is only available in Apache
275 <P>When placed into an <CODE>.htaccess</CODE> file or a
276 <CODE><Directory></CODE> or <CODE><Location></CODE> section,
277 this directive forces all matching files to be served
278 as the content type given by <EM>media type</EM>. For example, if you
279 had a directory full of GIF files, but did not want to label them all with
280 ".gif", you might want to use:
284 <P>Note that this will override any filename extensions that might determine
285 the media type.</P><HR>
287 <H2><A NAME="sethandler">SetHandler</A></H2>
290 HREF="directive-dict.html#Syntax"
292 ><STRONG>Syntax:</STRONG></A> SetHandler <EM>handler-name</EM><BR>
294 HREF="directive-dict.html#Context"
296 ><STRONG>Context:</STRONG></A> directory, .htaccess<BR>
298 HREF="directive-dict.html#Status"
300 ><STRONG>Status:</STRONG></A> Base<BR>
302 HREF="directive-dict.html#Module"
304 ><STRONG>Module:</STRONG></A> mod_mime<BR>
306 HREF="directive-dict.html#Compatibility"
308 ><STRONG>Compatibility:</STRONG></A> SetHandler is only available in Apache
311 <P>When placed into an <CODE>.htaccess</CODE> file or a
312 <CODE><Directory></CODE> or <CODE><Location></CODE> section,
313 this directive forces all matching files to be parsed through the
314 <A HREF="../handler.html">handler</A>
315 given by <EM>handler-name</EM>. For example, if you had a
316 directory you wanted to be parsed entirely as imagemap rule files,
317 regardless of extension, you might put the following into an
318 <CODE>.htaccess</CODE> file in that directory:
323 <P>Another example: if you wanted to have the server display a status
324 report whenever a URL of <CODE>http://servername/status</CODE> was
325 called, you might put the following into access.conf:
327 <Location /status>
328 SetHandler server-status
333 <H2><A NAME="typesconfig">TypesConfig</A></H2>
334 <!--%plaintext <?INDEX {\tt TypesConfig} directive> -->
336 HREF="directive-dict.html#Syntax"
338 ><STRONG>Syntax:</STRONG></A> TypesConfig <EM>filename</EM><BR>
340 HREF="directive-dict.html#Default"
342 ><STRONG>Default:</STRONG></A> <CODE>TypesConfig conf/mime.types</CODE><BR>
344 HREF="directive-dict.html#Context"
346 ><STRONG>Context:</STRONG></A> server config<BR>
348 HREF="directive-dict.html#Status"
350 ><STRONG>Status:</STRONG></A> Base<BR>
352 HREF="directive-dict.html#Module"
354 ><STRONG>Module:</STRONG></A> mod_mime<P>
356 The TypesConfig directive sets the location of the mime types configuration
357 file. <EM>Filename</EM> is relative to the
358 <A HREF="core.html#serverroot">ServerRoot</A>. This file sets the default list of
359 mappings from filename extensions to content types; changing this file is not
360 recommended. Use the <A HREF="#addtype">AddType</A> directive instead. The
361 file contains lines in the format of the arguments to an AddType command:
362 <BLOCKQUOTE><EM>MIME-type extension extension ...</EM></BLOCKQUOTE>
363 The extensions are lower-cased. Blank lines, and lines beginning with a hash
364 character (`#') are ignored.<P>
366 <!--#include virtual="footer.html" -->