]> granicus.if.org Git - apache/blob - docs/manual/mod/mod_mime.html
Another typo (missed this one on the first go-round).
[apache] / docs / manual / mod / mod_mime.html
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
2 <HTML>
3 <HEAD>
4 <TITLE>Apache module mod_mime</TITLE>
5 </HEAD>
6
7 <BODY>
8 <!--#include virtual="header.html" -->
9 <H1>Module mod_mime</h1>
10
11 This module is contained in the <code>mod_mime.c</code> file, and is
12 compiled in by default. It provides for determining the types of files
13 from the filename.
14
15 <h2>Summary</h2>
16 This module is used to determine the mime types of documents. Some mime
17 types indicate special processing to be performed by the server, otherwise
18 the type is returned to the client so that the browser can deal with
19 the document appropriately.<p>
20
21 The filename of a document is treated as being composed of a basename followed
22 by some extensions, in the following order:
23 <blockquote><em>base.type.language.enc</em></blockquote>
24 The <em>type</em> extension sets the type of the document; types are defined
25 in the <A HREF="#typesconfig">TypesConfig</A> file and by the
26 <A HREF="#addtype">AddType</A> directive. The <em>language</em> extension
27 sets the language of the document, as defined by the
28 <A HREF="#addlanguage">AddLanguage</A> directive. Finally, the
29 <em>enc</em> directive sets the encoding of the document, as defined by
30 the <A HREF="#addencoding">AddEncoding</A> directive.
31
32
33 <h2> Directives</h2>
34 <ul>
35 <li><A HREF="#addencoding">AddEncoding</A>
36 <li><A HREF="#addhandler">AddHandler</A>
37 <li><A HREF="#addlanguage">AddLanguage</A>
38 <li><A HREF="#addtype">AddType</A>
39 <li><A HREF="#forcetype">ForceType</A>
40 <li><A HREF="#sethandler">SetHandler</A>
41 <li><A HREF="#typesconfig">TypesConfig</A>
42 </ul>
43 <hr>
44
45
46 <h2><A name="addencoding">AddEncoding</A></h2>
47 <!--%plaintext &lt;?INDEX {\tt AddEncoding} directive&gt; -->
48 <strong>Syntax:</strong> AddEncoding <em>mime-enc extension extension...</em><br>
49 <Strong>Context:</strong> server config, virtual host, directory, .htaccess<br>
50 <Strong>Override:</strong> FileInfo<br>
51 <strong>Status:</strong> Base<br>
52 <strong>Module:</strong> mod_mime<p>
53
54 The AddEncoding directive adds to the list of filename extensions which
55 filenames may end in for the specified encoding type. <em>Mime-enc</em>
56 is the mime encoding to use for documents ending in <em>extension</em>.
57 Example:
58 <blockquote><code>
59 AddEncoding x-gzip gz<br>
60 AddEncoding x-compress Z
61 </code></blockquote>
62
63 This will cause files ending in .gz to be marked as encoded using the x-gzip
64 encoding, and .Z files to be marked as encoded with x-compress.<p><hr>
65
66 <h2><a name="addhandler">AddHandler</a></h2>
67
68 <strong>Syntax:</strong> &lt;AddHandler <em>handler-name extension</em>&gt;<br>
69 <strong>Context:</strong> server config, virtual host, directory, .htaccess<br>
70 <strong>Status:</strong> Base<br>
71 <strong>Module:</strong> mod_mime<br>
72 <strong>Compatibility:</strong> AddHandler is only available in Apache
73 1.1 and later<p>
74
75 <p>AddHandler maps the filename extension <em>extension</em> to the
76 <a href="../handler.html">handler</a>
77 <em>handler-name</em>. For example, to activate CGI scripts
78 with the file extension "<code>.cgi</code>", you might use:
79 <pre>
80     AddHandler cgi-script cgi
81 </pre>
82
83 <p>Once that has been put into your srm.conf or httpd.conf file, any
84 file ending with "<code>.cgi</code>" will be treated as a CGI
85 program.</p>
86 <HR>
87
88 <h2><A name="addlanguage">AddLanguage</A></h2>
89 <!--%plaintext &lt;?INDEX {\tt AddLanguage} directive&gt; -->
90 <strong>Syntax:</strong> AddLanguage <em>mime-lang extension extension...</em><br>
91 <Strong>Context:</strong> server config, virtual host, directory, .htaccess<br>
92 <Strong>Override:</strong> FileInfo<br>
93 <strong>Status:</strong> Base<br>
94 <strong>Module:</strong> mod_mime<p>
95
96 The AddLanguage directive adds to the list of filename extensions which
97 filenames may end in for the specified content language. <em>Mime-lang</em>
98 is the mime language of files with names ending <em>extension</em>,
99 after any content encoding extensions have been removed. Example:
100 <blockquote><code>
101 AddEncoding x-compress Z<br>
102 AddLanguage en .en<br>
103 AddLanguage fr .fr<br>
104 </code></blockquote>
105
106 Then the document <code>xxxx.en.Z</code> will be treated as being a compressed
107 English document. Although the content language is reported to the client,
108 the browser is unlikely to use this information. The AddLanguage directive
109 is more useful for content negotiation, where the server returns one
110 from several documents based on the client's language preference.<p><hr>
111
112 <h2><A name="addtype">AddType</A></h2>
113 <!--%plaintext &lt;?INDEX {\tt AddType} directive&gt; -->
114 <strong>Syntax:</strong> AddType <em>mime-type extension extension...</em><br>
115 <Strong>Context:</strong> server config, virtual host, directory, .htaccess<br>
116 <Strong>Override:</strong> FileInfo<br>
117 <strong>Status:</strong> Base<br>
118 <strong>Module:</strong> mod_mime<p>
119
120 The AddType directive adds to the list of filename extensions which
121 filenames may end in for the specified content type. <em>Mime-enc</em>
122 is the mime type to use for documents ending in <em>extension</em>.
123 after content-encoding and language extensions have been removed. Example:
124 <blockquote><code>
125 AddType image/gif GIF
126 </code></blockquote>
127 It is recommended that new mime types be added using the AddType directive
128 rather than changing the <A HREF="#typesconfig">TypesConfig</A> file.<p>
129 Note that, unlike the NCSA httpd, this directive cannot be used to set the
130 type of particular files.<p><hr>
131
132 <h2><a name="forcetype">ForceType</a></h2>
133
134 <strong>Syntax:</strong> &lt;ForceType <em>media type</em>&gt;<br>
135 <strong>Context:</strong> directory, .htaccess<br>
136 <strong>Status:</strong> Base<br>
137 <strong>Module:</strong> mod_mime<br>
138 <strong>Compatibility:</strong> ForceType is only available in Apache
139 1.1 and later.<p>
140
141 <p>When placed into an <code>.htaccess</code> file or a
142 <code>&lt;Directory&gt;</code> or <code>&lt;Location&gt;</code> section,
143 this directive forces all matching files to be served
144 as the content type given by <em>media type</em>. For example, if you
145 had a directory full of GIF files, but did not want to label them all with
146 ".gif", you might want to use:
147 <pre>
148     ForceType image/gif
149 </pre>
150 <p>Note that this will override any filename extensions that might
151 media type.</p>
152
153 <h2><a name="sethandler">SetHandler</a></h2>
154
155 <strong>Syntax:</strong> &lt;SetHandler <em>handler-name</em>&gt;<br>
156 <strong>Context:</strong> directory, .htaccess<br>
157 <strong>Status:</strong> Base<br>
158 <strong>Module:</strong> mod_mime<br>
159 <strong>Compatibility:</strong> SetHandler is only available in Apache
160 1.1 and later.<p>
161
162 <p>When placed into an <code>.htaccess</code> file or a
163 <code>&lt;Directory&gt;</code> or <code>&lt;Location&gt;</code> section,
164 this directive forces all matching files to be parsed through the
165 <a href="../handler.html">handler</a>
166 given by <em>handler-name</em>. For example, if you had a
167 directory you wanted to be parsed entirely as imagemap rule files,
168 regardless of extension, you might put the following into an
169 <code>.htaccess</code> file in that directory:
170 <pre>
171     SetHandler imap-file
172 </pre>
173
174 <p>Another example: if you wanted to have the server display a status
175 report whenever a URL of <code>http://servername/status</code> was
176 called, you might put the following into access.conf:
177 <pre>
178     &lt;Location /status&gt;
179     SetHandler server-status
180     &lt;/Location&gt;
181 </pre>
182 <HR>
183
184 <h2><A name="typesconfig">TypesConfig</A></h2>
185 <!--%plaintext &lt;?INDEX {\tt TypesConfig} directive&gt; -->
186 <strong>Syntax:</strong> TypesConfig <em>filename</em><br>
187 <strong>Default:</strong> <code>TypesConfig conf/mime.types</code><br>
188 <Strong>Context:</strong> server config<br>
189 <strong>Status:</strong> Base<br>
190 <strong>Module:</strong> mod_mime<p>
191
192 The TypesConfig directive sets the location of the mime types configuration
193 file. <em>Filename</em> is relative to the
194 <A HREF="core.html#serverroot">ServerRoot</A>. This file sets the default list of
195 mappings from filename extensions to content types; changing this file is not
196 recommended. Use the <A HREF="#addtype">AddType</A> directive instead. The
197 file contains lines in the format of the arguments to an AddType command:
198 <blockquote><em>mime-type extension extension ...</em></blockquote>
199 The extensions are lower-cased. Blank lines, and lines beginning with a hash
200 character (`#') are ignored.<p>
201
202 <!--#include virtual="footer.html" -->
203 </BODY>
204 </HTML>
205