1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>Apache module mod_mime</TITLE>
</HEAD>
<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
<BODY
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#000080"
ALINK="#FF0000"
>
<DIV ALIGN="CENTER">
<IMG SRC="../images/sub.gif" ALT="[APACHE DOCUMENTATION]">
<H3>
Apache HTTP Server Version 1.2
</H3>
</DIV>
<H1 ALIGN="CENTER">Module mod_mime</h1>
This module is contained in the <code>mod_mime.c</code> file, and is
compiled in by default. It provides for determining the types of files
from the filename.
<h2>Summary</h2>
This module is used to determine various bits of "meta information"
about documents. This information relates to the content of the
document and is returned to the browser or used in content-negotiation
within the server. In addition, a "handler" can be set for a document,
which determines how the document will be processed within the server.
<P>
The directives <A HREF="#addencoding">AddEncoding</A>, <A
HREF="#addhandler">AddHandler</A>, <A
HREF="#addlanguage">AddLanguage</A> and <A HREF="#addtype">AddType</A>
are all used to map file extensions onto the meta-information for that
file. Respectively they set the content-encoding, handler,
content-language and mime-type (content-type) of documents. The
directive <A HREF="#typesconfig">TypesConfig</A> is used to specify a
file which also maps extensions onto mime types. The directives <A
HREF="#forcetype">ForceType</A> and <A
HREF="#sethandler">SetHandler</A> are used to associated all the files
in a given location (e.g. a particular directory) onto a particular
mime type or handler.
<P>
Files can have more than one extension, and the order of the
extensions is normally irrelevant. For example, if the file
<CODE>welcome.html.fr</CODE> maps onto content type text/html and
language French then the file <CODE>welcome.fr.html</CODE> will map
onto exactly the same information. The only exception to this is if an
extension is given which Apache does not know how to handle. In this
case it will "forget" about any information it obtained from
extensions to the left of the unknown extension. So, for example, if
the extensions fr and html are mapped to the appropriate language and
type but extension xxx is not assigned to anything, then the file
<CODE>welcome.fr.xxx.html</CODE> will be associated with content-type
text/html but <i>no</i> language.
<P>
<h2> Directives</h2>
<ul>
<li><A HREF="#addencoding">AddEncoding</A>
<li><A HREF="#addhandler">AddHandler</A>
<li><A HREF="#addlanguage">AddLanguage</A>
<li><A HREF="#addtype">AddType</A>
<li><A HREF="#forcetype">ForceType</A>
<li><A HREF="#sethandler">SetHandler</A>
<li><A HREF="#typesconfig">TypesConfig</A>
</ul>
<hr>
<h2><A name="addencoding">AddEncoding</A></h2>
<!--%plaintext <?INDEX {\tt AddEncoding} directive> -->
<strong>Syntax:</strong> AddEncoding <em>mime-enc extension extension...</em><br>
<Strong>Context:</strong> server config, virtual host, directory, .htaccess<br>
<Strong>Override:</strong> FileInfo<br>
<strong>Status:</strong> Base<br>
<strong>Module:</strong> mod_mime<p>
The AddEncoding directive adds to the list of filename extensions which
filenames may end in for the specified encoding type. <em>Mime-enc</em>
is the mime encoding to use for documents ending in <em>extension</em>.
Example:
<blockquote><code>
AddEncoding x-gzip gz<br>
AddEncoding x-compress Z
</code></blockquote>
This will cause files ending in .gz to be marked as encoded using the x-gzip
encoding, and .Z files to be marked as encoded with x-compress.<p><hr>
<h2><a name="addhandler">AddHandler</a></h2>
<strong>Syntax:</strong> AddHandler <em>handler-name extension extension...</em><br>
<strong>Context:</strong> server config, virtual host, directory, .htaccess<br>
<strong>Status:</strong> Base<br>
<strong>Module:</strong> mod_mime<br>
<strong>Compatibility:</strong> AddHandler is only available in Apache
1.1 and later<p>
<p>AddHandler maps the filename extensions <em>extension</em> to the
<a href="../handler.html">handler</a>
<em>handler-name</em>. For example, to activate CGI scripts
with the file extension "<code>.cgi</code>", you might use:
<pre>
AddHandler cgi-script cgi
</pre>
<p>Once that has been put into your srm.conf or httpd.conf file, any
file ending with "<code>.cgi</code>" will be treated as a CGI
program.</p>
<HR>
<h2><A name="addlanguage">AddLanguage</A></h2>
<!--%plaintext <?INDEX {\tt AddLanguage} directive> -->
<strong>Syntax:</strong> AddLanguage <em>mime-lang extension extension...</em><br>
<Strong>Context:</strong> server config, virtual host, directory, .htaccess<br>
<Strong>Override:</strong> FileInfo<br>
<strong>Status:</strong> Base<br>
<strong>Module:</strong> mod_mime<p>
The AddLanguage directive adds to the list of filename extensions which
filenames may end in for the specified content language. <em>Mime-lang</em>
is the mime language of files with names ending <em>extension</em>,
after any content encoding extensions have been removed. Example:
<blockquote><code>
AddEncoding x-compress Z<br>
AddLanguage en .en<br>
AddLanguage fr .fr<br>
</code></blockquote>
Then the document <code>xxxx.en.Z</code> will be treated as being a compressed
English document. Although the content language is reported to the client,
the browser is unlikely to use this information. The AddLanguage directive
is more useful for content negotiation, where the server returns one
from several documents based on the client's language preference.<p><hr>
<h2><A name="addtype">AddType</A></h2>
<!--%plaintext <?INDEX {\tt AddType} directive> -->
<strong>Syntax:</strong> AddType <em>mime-type extension extension...</em><br>
<Strong>Context:</strong> server config, virtual host, directory, .htaccess<br>
<Strong>Override:</strong> FileInfo<br>
<strong>Status:</strong> Base<br>
<strong>Module:</strong> mod_mime<p>
The AddType directive adds to the list of filename extensions which
filenames may end in for the specified content type. <em>Mime-enc</em>
is the mime type to use for documents ending in <em>extension</em>.
after content-encoding and language extensions have been removed. Example:
<blockquote><code>
AddType image/gif GIF
</code></blockquote>
It is recommended that new mime types be added using the AddType directive
rather than changing the <A HREF="#typesconfig">TypesConfig</A> file.<p>
Note that, unlike the NCSA httpd, this directive cannot be used to set the
type of particular files.<p><hr>
<h2><a name="forcetype">ForceType</a></h2>
<strong>Syntax:</strong> ForceType <em>media type</em><br>
<strong>Context:</strong> directory, .htaccess<br>
<strong>Status:</strong> Base<br>
<strong>Module:</strong> mod_mime<br>
<strong>Compatibility:</strong> ForceType is only available in Apache
1.1 and later.<p>
<p>When placed into an <code>.htaccess</code> file or a
<code><Directory></code> or <code><Location></code> section,
this directive forces all matching files to be served
as the content type given by <em>media type</em>. For example, if you
had a directory full of GIF files, but did not want to label them all with
".gif", you might want to use:
<pre>
ForceType image/gif
</pre>
<p>Note that this will override any filename extensions that might
media type.</p>
<h2><a name="sethandler">SetHandler</a></h2>
<strong>Syntax:</strong> SetHandler <em>handler-name</em><br>
<strong>Context:</strong> directory, .htaccess<br>
<strong>Status:</strong> Base<br>
<strong>Module:</strong> mod_mime<br>
<strong>Compatibility:</strong> SetHandler is only available in Apache
1.1 and later.<p>
<p>When placed into an <code>.htaccess</code> file or a
<code><Directory></code> or <code><Location></code> section,
this directive forces all matching files to be parsed through the
<a href="../handler.html">handler</a>
given by <em>handler-name</em>. For example, if you had a
directory you wanted to be parsed entirely as imagemap rule files,
regardless of extension, you might put the following into an
<code>.htaccess</code> file in that directory:
<pre>
SetHandler imap-file
</pre>
<p>Another example: if you wanted to have the server display a status
report whenever a URL of <code>http://servername/status</code> was
called, you might put the following into access.conf:
<pre>
<Location /status>
SetHandler server-status
</Location>
</pre>
<HR>
<h2><A name="typesconfig">TypesConfig</A></h2>
<!--%plaintext <?INDEX {\tt TypesConfig} directive> -->
<strong>Syntax:</strong> TypesConfig <em>filename</em><br>
<strong>Default:</strong> <code>TypesConfig conf/mime.types</code><br>
<Strong>Context:</strong> server config<br>
<strong>Status:</strong> Base<br>
<strong>Module:</strong> mod_mime<p>
The TypesConfig directive sets the location of the mime types configuration
file. <em>Filename</em> is relative to the
<A HREF="core.html#serverroot">ServerRoot</A>. This file sets the default list of
mappings from filename extensions to content types; changing this file is not
recommended. Use the <A HREF="#addtype">AddType</A> directive instead. The
file contains lines in the format of the arguments to an AddType command:
<blockquote><em>mime-type extension extension ...</em></blockquote>
The extensions are lower-cased. Blank lines, and lines beginning with a hash
character (`#') are ignored.<p>
<HR>
<H3 ALIGN="CENTER">
Apache HTTP Server Version 1.2
</H3>
<A HREF="./"><IMG SRC="../images/index.gif" ALT="Index"></A>
<A HREF="../"><IMG SRC="../images/home.gif" ALT="Home"></A>
</BODY>
</HTML>
|