mod_mime.html revision e15efb65133619d06600dc277d340e8101a2f443
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<!--#include virtual="header.html" -->
60a4b2c422dcbb08a554fb193105c08da592718bpoirierThis module is contained in the <code>mod_mime.c</code> file, and is
60a4b2c422dcbb08a554fb193105c08da592718bpoiriercompiled in by default. It provides for determining the types of files
60a4b2c422dcbb08a554fb193105c08da592718bpoirierfrom the filename.
60a4b2c422dcbb08a554fb193105c08da592718bpoirierThis module is used to determine the mime types of documents. Some mime
60a4b2c422dcbb08a554fb193105c08da592718bpoiriertypes indicate special processing to be performed by the server, otherwise
60a4b2c422dcbb08a554fb193105c08da592718bpoirierthe type is returned to the client so that the browser can deal with
3f08db06526d6901aa08c110b5bc7dde6bc39905ndthe document appropriately.<p>
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjungThe filename of a document is treated as being composed of a basename followed
60a4b2c422dcbb08a554fb193105c08da592718bpoirierby some extensions, in the following order:
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<blockquote><em>base.type.language.enc</em></blockquote>
60a4b2c422dcbb08a554fb193105c08da592718bpoirierThe <em>type</em> extension sets the type of the document; types are defined
60a4b2c422dcbb08a554fb193105c08da592718bpoirierin the <A HREF="#typesconfig">TypesConfig</A> file and by the
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<A HREF="#addtype">AddType</A> directive. The <em>language</em> extension
60a4b2c422dcbb08a554fb193105c08da592718bpoiriersets the language of the document, as defined by the
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<A HREF="#addlanguage">AddLanguage</A> directive. Finally, the
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<em>enc</em> directive sets the encoding of the document, as defined by
60a4b2c422dcbb08a554fb193105c08da592718bpoirierthe <A HREF="#addencoding">AddEncoding</A> directive.
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<!--%plaintext <?INDEX {\tt AddEncoding} directive> -->
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<strong>Syntax:</strong> AddEncoding <em>mime-enc extension extension...</em><br>
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<Strong>Context:</strong> server config, virtual host, directory, .htaccess<br>
60a4b2c422dcbb08a554fb193105c08da592718bpoirierThe AddEncoding directive adds to the list of filename extensions which
60a4b2c422dcbb08a554fb193105c08da592718bpoirierfilenames may end in for the specified encoding type. <em>Mime-enc</em>
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sfis the mime encoding to use for documents ending in <em>extension</em>.
60a4b2c422dcbb08a554fb193105c08da592718bpoirierAddEncoding x-gzip gz<br>
60a4b2c422dcbb08a554fb193105c08da592718bpoirierAddEncoding x-compress Z
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sfThis will cause files ending in .gz to be marked as encoded using the x-gzip
60a4b2c422dcbb08a554fb193105c08da592718bpoirierencoding, and .Z files to be marked as encoded with x-compress.<p><hr>
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<strong>Syntax:</strong> <AddHandler <em>handler-name extension</em>><br>
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<strong>Context:</strong> server config, virtual host, directory, .htaccess<br>
a04dcd330b05345681a4057702b2d43b2042e21dtrawick<strong>Compatibility:</strong> AddHandler is only available in Apache
a04dcd330b05345681a4057702b2d43b2042e21dtrawick1.1 and later<p>
f8b7daeb0e3f0ac4544fcc665de10c6b69a1ce0dsf<p>AddHandler maps the filename extension <em>extension</em> to the
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<em>handler-name</em>. For example, to activate CGI scripts
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sfwith the file extension "<code>.cgi</code>", you might use:
60a4b2c422dcbb08a554fb193105c08da592718bpoirier AddHandler cgi-script cgi
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<p>Once that has been put into your srm.conf or httpd.conf file, any
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sffile ending with "<code>.cgi</code>" will be treated as a CGI
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sfprogram.</p>
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<!--%plaintext <?INDEX {\tt AddLanguage} directive> -->
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<strong>Syntax:</strong> AddLanguage <em>mime-lang extension extension...</em><br>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<Strong>Context:</strong> server config, virtual host, directory, .htaccess<br>
bed3c2e56e8f3328e780200466b9d009093db468sfThe AddLanguage directive adds to the list of filename extensions which
bed3c2e56e8f3328e780200466b9d009093db468sffilenames may end in for the specified content language. <em>Mime-lang</em>
bed3c2e56e8f3328e780200466b9d009093db468sfis the mime language of files with names ending <em>extension</em>,
bed3c2e56e8f3328e780200466b9d009093db468sfafter any content encoding extensions have been removed. Example:
bed3c2e56e8f3328e780200466b9d009093db468sfAddEncoding x-compress Z<br>
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sfAddLanguage en .en<br>
60a4b2c422dcbb08a554fb193105c08da592718bpoirierAddLanguage fr .fr<br>
60a4b2c422dcbb08a554fb193105c08da592718bpoirierThen the document <code>xxxx.en.Z</code> will be treated as being a compressed
60a4b2c422dcbb08a554fb193105c08da592718bpoirierEnglish document. Although the content language is reported to the client,
60a4b2c422dcbb08a554fb193105c08da592718bpoirierthe browser is unlikely to use this information. The AddLanguage directive
60a4b2c422dcbb08a554fb193105c08da592718bpoirieris more useful for content negotiation, where the server returns one
60a4b2c422dcbb08a554fb193105c08da592718bpoirierfrom several documents based on the client's language preference.<p><hr>
fe1c96d8f3b0c1f7e75eb8feb0170432bd91c951sf<!--%plaintext <?INDEX {\tt AddType} directive> -->
bcb2c4ef861e8f8260284631b6753e1088643c8asf<strong>Syntax:</strong> AddType <em>mime-type extension extension...</em><br>
bcb2c4ef861e8f8260284631b6753e1088643c8asf<Strong>Context:</strong> server config, virtual host, directory, .htaccess<br>
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sfThe AddType directive adds to the list of filename extensions which
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sffilenames may end in for the specified content type. <em>Mime-enc</em>
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sfis the mime type to use for documents ending in <em>extension</em>.
60a4b2c422dcbb08a554fb193105c08da592718bpoirierafter content-encoding and language extensions have been removed. Example:
60a4b2c422dcbb08a554fb193105c08da592718bpoirierIt is recommended that new mime types be added using the AddType directive
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sfrather than changing the <A HREF="#typesconfig">TypesConfig</A> file.<p>
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sfNote that, unlike the NCSA httpd, this directive cannot be used to set the
0236ede61169f34359c234625a1d792b97d7db12nd<strong>Syntax:</strong> <ForceType <em>media type</em>><br>
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<strong>Compatibility:</strong> ForceType is only available in Apache
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf1.1 and later.<p>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<p>When placed into an <code>.htaccess</code> file or a
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<code><Directory></code> or <code><Location</code> section,
60a4b2c422dcbb08a554fb193105c08da592718bpoirierthis directive forces all matching files to be served
60a4b2c422dcbb08a554fb193105c08da592718bpoirieras the content type given by <em>media type</em>. For example, if you
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sfhad a directory full of GIF files, but did not want to label them all with
60a4b2c422dcbb08a554fb193105c08da592718bpoirier".gif", you might want to use:
fed47023e9be04c612b5f6d4a5ee2b8e7c587181rbowen<p>Note that this will override any filename extensions that might
fed47023e9be04c612b5f6d4a5ee2b8e7c587181rbowenmedia type.</p>
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<strong>Syntax:</strong> <SetHandler <em>handler-name</em>><br>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<strong>Compatibility:</strong> SetHandler is only available in Apache
60a4b2c422dcbb08a554fb193105c08da592718bpoirier1.1 and later.<p>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<p>When placed into an <code>.htaccess</code> file or a
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<code><Directory></code> or <code><Location</code> section,
60a4b2c422dcbb08a554fb193105c08da592718bpoirierthis directive forces all matching files to be parsed through the
60a4b2c422dcbb08a554fb193105c08da592718bpoiriergiven by <em>handler-name</em>. For example, if you had a
60a4b2c422dcbb08a554fb193105c08da592718bpoirierdirectory you wanted to be parsed entirely as imagemap rule files,
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sfregardless of extension, you might put the following into an
60a4b2c422dcbb08a554fb193105c08da592718bpoirier SetHandler imap-file
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<p>Another example: if you wanted to have the server display a status
60a4b2c422dcbb08a554fb193105c08da592718bpoirierreport whenever a URL of <code>http://servername/status</code> was
60a4b2c422dcbb08a554fb193105c08da592718bpoiriercalled, you might put the following into access.conf:
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <Location /status>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier SetHandler server-status
60a4b2c422dcbb08a554fb193105c08da592718bpoirier </Location>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<!--%plaintext <?INDEX {\tt TypesConfig} directive> -->
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<strong>Syntax:</strong> TypesConfig <em>filename</em><br>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<strong>Default:</strong> <code>TypesConfig conf/mime.types</code><br>
60a4b2c422dcbb08a554fb193105c08da592718bpoirierThe TypesConfig directive sets the location of the mime types configuration
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<A HREF="core.html#serverroot">ServerRoot</A>. This file sets the default list of
60a4b2c422dcbb08a554fb193105c08da592718bpoiriermappings from filename extensions to content types; changing this file is not
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sfrecommended. Use the <A HREF="#addtype">AddType</A> directive instead. The
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sffile contains lines in the format of the arguments to an AddType command:
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<blockquote><em>mime-type extension extension ...</em></blockquote>
60a4b2c422dcbb08a554fb193105c08da592718bpoirierThe extensions are lower-cased. Blank lines, and lines beginning with a hash
60a4b2c422dcbb08a554fb193105c08da592718bpoiriercharacter (`#') are ignored.<p>
5cd08ee4a8f5a665e656f70048a1268a02bc0e73sf<!--#include virtual="footer.html" -->