How to add MIME types?

MIME types are a way of instructing the browser, which is opening a particular file from the server, how to handle it. For example an .html file is of a text/html MIME type and this instructs your browser to interpret all of the files that use that extension as HTML Document files.

This can be useful when for example you want to get the visitor’s browser to download an mp3 file instead of playing it in the browser.

To define a new MIME type you should add the following line in a file named .htaccess in the folder where the files for your website reside:

AddType TYPE .extension

You should replace TYPE with the desired MIME type and .extension with the file extension you want it to apply for.

A full list of the available registered MIME types can be found at http://www.iana.org/assignments/media-types/.

Was this article helpful?

Related Articles