]> granicus.if.org Git - apache/blob - docs/manual/mod/mod_mime.html
Update the summary part of mod_mime documentation to:
[apache] / docs / manual / mod / mod_mime.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2 <HTML>
3 <HEAD>
4 <TITLE>Apache module mod_mime</TITLE>
5 </HEAD>
6
7 <!-- Background white, links blue (unvisited), navy (visited), red (active) -->
8 <BODY
9  BGCOLOR="#FFFFFF"
10  TEXT="#000000"
11  LINK="#0000FF"
12  VLINK="#000080"
13  ALINK="#FF0000"
14 >
15 <!--#include virtual="header.html" -->
16 <H1 ALIGN="CENTER">Module mod_mime</h1>
17
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
20 from the filename.
21
22 <h2>Summary</h2>
23
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.
29
30 <P>
31
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
43 mime type or handler.
44
45 <P>
46
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 <i>no</i> language.
59
60 <P>
61
62 <h2> Directives</h2>
63 <ul>
64 <li><A HREF="#addencoding">AddEncoding</A>
65 <li><A HREF="#addhandler">AddHandler</A>
66 <li><A HREF="#addlanguage">AddLanguage</A>
67 <li><A HREF="#addtype">AddType</A>
68 <li><A HREF="#forcetype">ForceType</A>
69 <li><A HREF="#sethandler">SetHandler</A>
70 <li><A HREF="#typesconfig">TypesConfig</A>
71 </ul>
72 <hr>
73
74
75 <h2><A name="addencoding">AddEncoding</A></h2>
76 <!--%plaintext &lt;?INDEX {\tt AddEncoding} directive&gt; -->
77 <strong>Syntax:</strong> AddEncoding <em>mime-enc extension extension...</em><br>
78 <Strong>Context:</strong> server config, virtual host, directory, .htaccess<br>
79 <Strong>Override:</strong> FileInfo<br>
80 <strong>Status:</strong> Base<br>
81 <strong>Module:</strong> mod_mime<p>
82
83 The AddEncoding directive adds to the list of filename extensions which
84 filenames may end in for the specified encoding type. <em>Mime-enc</em>
85 is the mime encoding to use for documents ending in <em>extension</em>.
86 Example:
87 <blockquote><code>
88 AddEncoding x-gzip gz<br>
89 AddEncoding x-compress Z
90 </code></blockquote>
91
92 This will cause files ending in .gz to be marked as encoded using the x-gzip
93 encoding, and .Z files to be marked as encoded with x-compress.<p><hr>
94
95 <h2><a name="addhandler">AddHandler</a></h2>
96
97 <strong>Syntax:</strong> AddHandler <em>handler-name extension extension...</em><br>
98 <strong>Context:</strong> server config, virtual host, directory, .htaccess<br>
99 <strong>Status:</strong> Base<br>
100 <strong>Module:</strong> mod_mime<br>
101 <strong>Compatibility:</strong> AddHandler is only available in Apache
102 1.1 and later<p>
103
104 <p>AddHandler maps the filename extensions <em>extension</em> to the
105 <a href="../handler.html">handler</a>
106 <em>handler-name</em>. For example, to activate CGI scripts
107 with the file extension "<code>.cgi</code>", you might use:
108 <pre>
109     AddHandler cgi-script cgi
110 </pre>
111
112 <p>Once that has been put into your srm.conf or httpd.conf file, any
113 file ending with "<code>.cgi</code>" will be treated as a CGI
114 program.</p>
115 <HR>
116
117 <h2><A name="addlanguage">AddLanguage</A></h2>
118 <!--%plaintext &lt;?INDEX {\tt AddLanguage} directive&gt; -->
119 <strong>Syntax:</strong> AddLanguage <em>mime-lang extension extension...</em><br>
120 <Strong>Context:</strong> server config, virtual host, directory, .htaccess<br>
121 <Strong>Override:</strong> FileInfo<br>
122 <strong>Status:</strong> Base<br>
123 <strong>Module:</strong> mod_mime<p>
124
125 The AddLanguage directive adds to the list of filename extensions which
126 filenames may end in for the specified content language. <em>Mime-lang</em>
127 is the mime language of files with names ending <em>extension</em>,
128 after any content encoding extensions have been removed. Example:
129 <blockquote><code>
130 AddEncoding x-compress Z<br>
131 AddLanguage en .en<br>
132 AddLanguage fr .fr<br>
133 </code></blockquote>
134
135 Then the document <code>xxxx.en.Z</code> will be treated as being a compressed
136 English document. Although the content language is reported to the client,
137 the browser is unlikely to use this information. The AddLanguage directive
138 is more useful for content negotiation, where the server returns one
139 from several documents based on the client's language preference.<p><hr>
140
141 <h2><A name="addtype">AddType</A></h2>
142 <!--%plaintext &lt;?INDEX {\tt AddType} directive&gt; -->
143 <strong>Syntax:</strong> AddType <em>mime-type extension extension...</em><br>
144 <Strong>Context:</strong> server config, virtual host, directory, .htaccess<br>
145 <Strong>Override:</strong> FileInfo<br>
146 <strong>Status:</strong> Base<br>
147 <strong>Module:</strong> mod_mime<p>
148
149 The AddType directive adds to the list of filename extensions which
150 filenames may end in for the specified content type. <em>Mime-enc</em>
151 is the mime type to use for documents ending in <em>extension</em>.
152 after content-encoding and language extensions have been removed. Example:
153 <blockquote><code>
154 AddType image/gif GIF
155 </code></blockquote>
156 It is recommended that new mime types be added using the AddType directive
157 rather than changing the <A HREF="#typesconfig">TypesConfig</A> file.<p>
158 Note that, unlike the NCSA httpd, this directive cannot be used to set the
159 type of particular files.<p><hr>
160
161 <h2><a name="forcetype">ForceType</a></h2>
162
163 <strong>Syntax:</strong> ForceType <em>media type</em><br>
164 <strong>Context:</strong> directory, .htaccess<br>
165 <strong>Status:</strong> Base<br>
166 <strong>Module:</strong> mod_mime<br>
167 <strong>Compatibility:</strong> ForceType is only available in Apache
168 1.1 and later.<p>
169
170 <p>When placed into an <code>.htaccess</code> file or a
171 <code>&lt;Directory&gt;</code> or <code>&lt;Location&gt;</code> section,
172 this directive forces all matching files to be served
173 as the content type given by <em>media type</em>. For example, if you
174 had a directory full of GIF files, but did not want to label them all with
175 ".gif", you might want to use:
176 <pre>
177     ForceType image/gif
178 </pre>
179 <p>Note that this will override any filename extensions that might
180 media type.</p>
181
182 <h2><a name="sethandler">SetHandler</a></h2>
183
184 <strong>Syntax:</strong> SetHandler <em>handler-name</em><br>
185 <strong>Context:</strong> directory, .htaccess<br>
186 <strong>Status:</strong> Base<br>
187 <strong>Module:</strong> mod_mime<br>
188 <strong>Compatibility:</strong> SetHandler is only available in Apache
189 1.1 and later.<p>
190
191 <p>When placed into an <code>.htaccess</code> file or a
192 <code>&lt;Directory&gt;</code> or <code>&lt;Location&gt;</code> section,
193 this directive forces all matching files to be parsed through the
194 <a href="../handler.html">handler</a>
195 given by <em>handler-name</em>. For example, if you had a
196 directory you wanted to be parsed entirely as imagemap rule files,
197 regardless of extension, you might put the following into an
198 <code>.htaccess</code> file in that directory:
199 <pre>
200     SetHandler imap-file
201 </pre>
202
203 <p>Another example: if you wanted to have the server display a status
204 report whenever a URL of <code>http://servername/status</code> was
205 called, you might put the following into access.conf:
206 <pre>
207     &lt;Location /status&gt;
208     SetHandler server-status
209     &lt;/Location&gt;
210 </pre>
211 <HR>
212
213 <h2><A name="typesconfig">TypesConfig</A></h2>
214 <!--%plaintext &lt;?INDEX {\tt TypesConfig} directive&gt; -->
215 <strong>Syntax:</strong> TypesConfig <em>filename</em><br>
216 <strong>Default:</strong> <code>TypesConfig conf/mime.types</code><br>
217 <Strong>Context:</strong> server config<br>
218 <strong>Status:</strong> Base<br>
219 <strong>Module:</strong> mod_mime<p>
220
221 The TypesConfig directive sets the location of the mime types configuration
222 file. <em>Filename</em> is relative to the
223 <A HREF="core.html#serverroot">ServerRoot</A>. This file sets the default list of
224 mappings from filename extensions to content types; changing this file is not
225 recommended. Use the <A HREF="#addtype">AddType</A> directive instead. The
226 file contains lines in the format of the arguments to an AddType command:
227 <blockquote><em>mime-type extension extension ...</em></blockquote>
228 The extensions are lower-cased. Blank lines, and lines beginning with a hash
229 character (`#') are ignored.<p>
230
231 <!--#include virtual="footer.html" -->
232 </BODY>
233 </HTML>
234