What are MIME types and how can I define them on my server?

This FAQ will help you to define MIME types on your server

This process works slightly differently depending on the type of server you are operating. Below, we have split the step by step instructions between Linux and Windows servers, so that you can follow the process applicable to your server.

What is a MIME type? Mime types are used to allow the exchange of different data types across the internet. These processes allow the exchange of audio, video, images and applications, along with other data types.

Windows

This code will allow you to add or change a MIME type extension:

<configuration>
<system.webServer>
<staticContent>
<remove fileExtension=”.extension” />
<mimeMap fileExtension=”.extension” mimeType=”application/example” />
</staticContent>
</system.webServer>
</configuration>

In the below example, we are changing the server level MIME type from .pdf application/pdf to application/octet-stream to force the PDF file to download.

This code also removes the file extension. This is required in order to prevent the creation of 500 errors.

<configuration>
<system.webServer>
<staticContent>
<remove fileExtension=”.pdf” />
<mimeMap fileExtension=”.pdf” mimeType=”application/octet-stream” />
</staticContent>
</system.webServer>
</configuration>

Linux

To add MIME types to your Linux server, you can use the AddType directive in your .htaccess file. For example, the below command would be used to force a .pdf file to be downloaded when accessed.

AddType application/octet-stream .pdf