MIME Types

application/msword application/news-message-id application/news-transmission application/ocsp-request application/ocsp-response application/octet-stream application/oda application/parityfec application/pdf doc bin dms lha lzh exe class so dll oda pdf

_ MIME is a somewhat antiquated acronym. The Apache documentation refers to this data by its common name today — Internet media types. This new name reflects the use of MIME for more than just mail.

Apache uses this data to indicate what should be done with specific files. For example, Session 2 covered the installation of PHP and added the following two lines to the Apache httpd.conf file:

AddType application/x-httpd-php .php .phtml

AddType application/x-httpd-php-source .phps

The first line tells Apache that files that have .php or .phtml extensions are PHP files and should be treated as such — namely, run through the PHP engine as per instructions in the PHP module. Likewise, when a nonbrowser-compliant MIME type is encountered (as in the earlier .doc example), Apache passes the MIME type definition on to the browser. If the browser knows how to handle the type, it does so (by loading MS Word, Adobe Acrobat, or another required helper).

You can use the AddType directive to add additional types or change existing types. For example, you can add other extensions to the PHP MIME definition to cause the PHP engine to parse files with those extensions. However, each type you add is put through the PHP engine whether any PHP code is enclosed in the file or not. For that reason, you should add only those extensions you know will always contain at least some PHP code.

Was this article helpful?

+3 0

Post a comment