mod_mime_magic.html revision 240a5b8962329911d02566b600be6226e1f857ae
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose<html xmlns="http://www.w3.org/TR/xhtml1/strict"><head><!--
04feeade1f6259368a6b23c6b3ecbad261161659Sumit BoseXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose This file is generated from xml source: DO NOT EDIT
04feeade1f6259368a6b23c6b3ecbad261161659Sumit BoseXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose--><title>mod_mime_magic - Apache HTTP Server</title><link rel="stylesheet" type="text/css" href="/style/manual.css"/></head><body><blockquote><div align="center"><img src="/images/sub.gif" alt="[APACHE DOCUMENTATION]"/><h3>Apache HTTP Server Version 2.0</h3></div><h1 align="center">Apache Module mod_mime_magic</h1><table bgcolor="#cccccc" cellpadding="0" cellspacing="1"><tr><td><table bgcolor="#ffffff"><tr><td valign="top"><span class="help">Description:</span></td><td>Determines the MIME type of a file
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose by looking at a few bytes of its contents</td></tr><tr><td><a class="help" href="module-dict.html#Status">Status:</a></td><td>Extension</td></tr><tr><td><a class="help" href="module-dict.html#ModuleIdentifier">Module Identifier:</a></td><td>mime_magic_module</td></tr></table></td></tr></table><h2>Summary</h2>
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose <p>This module determines the MIME type of files in the same
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose way the Unix file(1) command works: it looks at the first few
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose bytes of the file. It is intended as a "second line of defense"
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose for cases that <code><a href="mod_mime.html">mod_mime</a></code> can't
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose resolve. To assure that mod_mime gets first try at determining
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose a file's MIME type, be sure to list mod_mime_magic
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose <strong>before</strong> mod_mime in the configuration.</p>
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose <p>This module is derived from a free version of the
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose <code>file(1)</code> command for Unix, which uses "magic
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose numbers" and other hints from a file's contents to figure out
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose what the contents are. This module is active only if the magic
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose file is specified by the <a class="directive" href="#mimemagicfile"><code class="directive">MimeMagicFile</code></a> directive.</p>
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose<h2>Directives</h2><ul><li><a href="#mimemagicfile">MimeMagicFile</a></li></ul><h2>Format of the Magic File</h2>
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose <p>The contents of the file are plain ASCII text in 4-5
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose columns. Blank lines are allowed but ignored. Commented lines
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose use a hash mark "#". The remaining lines are parsed for the
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose following columns:</p>
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose ">" indicates a dependency upon the previous non-">"
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose type of data to match
4e9631a9f1ae87317eef53145622099c46196b56Jakub Hrozek <td>long integer date (seconds since Unix
7c9d530b83a5b2469533e232ca7d5af508e03901Jakub Hrozek <p>For example, the following magic file lines would recognize
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose some audio formats.</p>
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose<blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose0 string .snd
7c9d530b83a5b2469533e232ca7d5af508e03901Jakub Hrozek <p>Or these would recognize the difference between "*.doc" files
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose containing Microsoft Word or FrameMaker documents. (These are
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose incompatible file formats which use the same file suffix.)</p>
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose<blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
7c9d530b83a5b2469533e232ca7d5af508e03901Jakub Hrozek0 string \320\317\021\340\241\261 application/msword
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov0 string \333\245-\0\0\0 application/msword
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose <p>An optional MIME encoding can be included as a fifth column.
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose For example, this can recognize gzipped files and set the
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose encoding for them.</p>
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose<blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov# gzip (GNU zip, not to be confused with [Info-ZIP/PKWARE] zip archiver)
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose <p>This module is not for every system. If your system is barely
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose keeping up with its load or if you're performing a web server
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose benchmark, you may not want to enable this because the
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov processing is not free.</p>
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose <p>However, an effort was made to improve the performance of
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose the original file(1) code to make it fit in a busy web server.
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose It was designed for a server where there are thousands of users
19a410288778a3aaf6a01bc71cacb8cb46465875Lukas Slebodnik who publish their own documents. This is probably very common
bd92e8ee315d4da9350b9ef0358c88a7b54aeebeStephen Gallagher on intranets. Many times, it's helpful if the server can make
bd92e8ee315d4da9350b9ef0358c88a7b54aeebeStephen Gallagher more intelligent decisions about a file's contents than the
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose file name allows ...even if just to reduce the "why doesn't my
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov page work" calls when users improperly name their own files.
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose You have to decide if the extra work suits your
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose environment.</p>
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose <p>When compiling an Apache server, this module should be at or
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose near the top of the list of modules in the Configuration file.
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose The modules are listed in increasing priority so that will mean
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose this one is used only as a last resort, just like it was
04feeade1f6259368a6b23c6b3ecbad261161659Sumit Bose designed to.</p>
* originally posted to comp.sources.unix. Copyright info for that program
<hr/><h2><a name="MimeMagicFile">MimeMagicFile</a> <a name="mimemagicfile">Directive</a></h2><table bgcolor="#cccccc" border="0" cellspacing="0" cellpadding="1"><tr><td><table bgcolor="#ffffff"><tr><td><strong>Description: </strong></td><td>Enable MIME-type determination based on file contents
using the specified magic file</td></tr><tr><td><a class="help" href="directive-dict.html#Syntax">Syntax:</a></td><td>MimeMagicFile <em>file-path</em></td></tr><tr><td><a class="help" href="directive-dict.html#Context">Context:</a></td><td>server config, virtual host</td></tr><tr><td><a class="help" href="directive-dict.html#Status">Status:</a></td><td>Extension</td></tr><tr><td><a class="help" href="directive-dict.html#Module">Module:</a></td><td>mod_mime_magic</td></tr></table></td></tr></table>