Apache HTTP Server Version 2.4
Description: | Determines the MIME type of a file by looking at a few bytes of its contents |
---|---|
Status: | Extension |
Module Identifier: | mime_magic_module |
Source File: | mod_mime_magic.c |
This module determines the MIME
type of files in the same way the Unix
file(1)
command works: it looks at the first few
bytes of the file. It is intended as a "second line of defense"
for cases that mod_mime
can't resolve.
This module is derived from a free version of the
file(1)
command for Unix, which uses "magic
numbers" and other hints from a file's contents to figure out
what the contents are. This module is active only if the magic
file is specified by the MimeMagicFile
directive.
The contents of the file are plain ASCII text in 4-5
columns. Blank lines are allowed but ignored. Commented lines
use a hash mark (#
). The remaining lines are parsed for
the following columns:
Column | Description | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | byte number to begin checking from " > " indicates a dependency upon the previous
non-"> " line | ||||||||||||||||||||||
2 | type of data to match
| ||||||||||||||||||||||
3 | contents of data to match | ||||||||||||||||||||||
4 | MIME type if matched | ||||||||||||||||||||||
5 | MIME encoding if matched (optional) |
For example, the following magic file lines would recognize some audio formats:
# Sun/NeXT audio data 0 string .snd >12 belong 1 audio/basic >12 belong 2 audio/basic >12 belong 3 audio/basic >12 belong 4 audio/basic >12 belong 5 audio/basic >12 belong 6 audio/basic >12 belong 7 audio/basic >12 belong 23 audio/x-adpcm
Or these would recognize the difference between *.doc
files containing Microsoft Word