h5bp / server-configs

Boilerplate configurations for various web servers.
3.1k stars 412 forks source link

Added Microsoft MIME Types + Force Download Options #159

Closed nico3333fr closed 11 years ago

nico3333fr commented 11 years ago

Adding microsoft MIME types and Force download for some files avoid bugs (for example, xlsx opened in Firefox, etc.).

See references : http://www.amember.com/forum/threads/force-file-downloads-with-htaccess.14980/ http://www.saelboat.com/blog/2012/12/htaccess-guide-force-downloads-of-mp3s-pdfs-and-other-media-files-299

alrra commented 11 years ago

From http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.5.1 :

19.5.1 Content-Disposition

The Content-Disposition response-header field has been proposed as a means for the origin server to suggest a default filename if the user requests that the content is saved to a file. ... An example is: Content-Disposition: attachment; filename="fname.ext" ... If this header is used in a response with the application/octet- stream content-type, the implied suggestion is that the user agent should not display the response, but directly enter a `save response as...' dialog.


for example, xlsx opened in Firefox, etc

@nico3333fr: tested (on Mac OS X 10.8.4, using Apache/2.2.22) for a couple of Microsoft Office file formats and browsers don't seem to have any problems downloading them by default.

Force download for some files

Personally, I don't find this as a good default and I think it should not be included without a real use case. Forcing the download of some file format can be a very specific / subjective thing that is better left to the developer (e.g.: I'm ok with my browser playing a video file or showing a pdf if it can, but also, in some cases, I prefer the server to force the download of some of the pngs, such as the ones from a specific path or the ones that are automatically generated, but more importantly, not all pngs).

@nico3333fr: If you don't agree with the above, feel free to contradict me!

Also, thanks for taking the time to make this pull request!