So, how does the system associate MIME content types with files? There are two ways.
Content analysis. The first is to look in the file's content and deduce the MIME content type from the content.
You can see this mechanism in action with the
file command. This command can give a
"human readable" description of a file's content
type or, with the -i
option, it can give a MIME
content type.
$ file course.pdf course.pdf: PDF document, version 1.2 $ file course.ps course.ps: PostScript document text conforming at level 2.0 $ file -i course.ps course.ps: application/postscript $ file -i course.pdf course.pdf: application/pdf
The file /usr/share/misc/magic is used to store the information about how to map from content to MIME type. The file /usr/share/misc/magic.mime is used for the more verbose descriptions.
File name analysis. The other approach is to use the file name. In particular it is traditional that files should have particular suffices according to their MIME content types. This is the most commonly used approach.
This approach is taken by other utilities than just the web server and there is a system wide file giving the correspondence between file names and MIME content types. This file is /etc/mime.types which is part of the SLES base system (as part of the aaa-base package).
application/msword doc application/pdf pdf application/postscript ai eps ps application/rtf rtf application/x-bzip2 bz2 application/x-dvi dvi application/xml audio/mpeg mpga mp2 mp3 image/png png model/vrml wrl vrml text/html html htm text/plain asc txt video/mpeg mpeg mpg mpe video/quicktime qt mov
Apache is capable of both modes of operation. We will use the latter as it is more common. This is for historical reasons and is not a reflection on the relative values of the two mechanisms.