ID #231

How can I make apache recognize different MIME types?

Applies to: Grid System

You use one or more AddType directives in an .htaccess file located in or above the directory where you want the new types to be recognized.

The .htaccess file is just a plain text file with 1 directive per line like:

AddType text/html .html
AddType image/gif .gif

The AddType directive is fully documented at http://httpd.apache.org/docs/mod/mod_mime.html#addtype

Last update: 2010-10-03 16:42
Author: FAQ Admin
Revision: 1.2

Digg it! Share on Facebook Print this record Send FAQ to a friend Show this as PDF file
Please rate this FAQ:

Average rating: 5 (4 Votes)

completely useless 1 2 3 4 5 most valuable

You can comment this FAQ

Comment of Anonymous:
If you want to let people download an OpenOffice document with an .odt extension and are having a problem with binary data from the document opening inside the browser, just add the following directive to an .htaccess file located above all the directories where you want it to operate:

AddType application/vnd.oasis.opendocument.text .odt

Doing that will change the behavior to make the user's browser prompt to either open the document with OpenOffice (or some other application) or "Save to Disk."
Added at: 2007-03-27 23:10

Comment of Anonymous:
To prevent .docx documents from being displayed in browsers you can add the following to a .htaccess which should force the browser to download the file as opposed to display it:

AddType application/vnd.openxmlformats-officedocument.wordprocessingml.document .docx

More info:

Added at: 2009-08-06 23:36