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