Suffix

Apache AddHandler or AddType directive?

What are the differences between the AddHandler and AddType Apache directives?

Both directives seem to define how the contents of a file with a given extension should be threatened but when do you need the first one and when the second?

The AddType handler specifies how the client (think about a browser) must deal with a particular data stream (e.g., download a binary or show an image or HTML page). The AddHandler, on the other hand, maps a handler to the file extension telling the server what to do with it. If you define a Ruby on Rails or PHP content type you will need the AddHandler, telling the server it should parse the file. If you define a JavaScript or HTML file, you will need the AddType one to tell the browser what content type to expect.

Strict versus quirks mode

Something slightly related is how browsers deal with the content type you set in the AddType directive. Gecko-based browsers (like Firefox) follow the standard closely so they will handle a file according to the content type from the Apache configuration. An image would show up as text if you wrongly assigned the text/plain content type. Internet Explorer is more flexible and tries to guess the mime type for misconfigured web servers showing a wrongly defined image as, well, an image.

More resources