I'm building a web server distributing variety kind of binary files. (with Ubuntu) They have vary extensions and sometimes has wrong extension. But currently, my Apache server serves unknown files as text. So I have to make my Apache2 serve all files as binary by default regardless of extension or any metadata except some explicit cases. How can I archive this?

link|improve this question

70% accept rate
feedback

1 Answer

up vote 2 down vote accepted

Try this directive on your site configuration:

DefaultType application/octet-stream

Or this one:

DefaultType None

The default seems to be text/plain:

DefaultType Directive
Description:    MIME content-type that will be sent if the server cannot determine a type in any other way
Syntax: DefaultType MIME-type|none
Default:    DefaultType text/plain
Context:    server config, virtual host, directory, .htaccess

http://httpd.apache.org/docs/2.2/mod/core.html#defaulttype

link|improve this answer
This is correct, but I'll add two points: one, don't test with Internet Explorer, which tries to guess content types; use Firefox (or another decent browser). Also, DefaultType None should be the default configuration; check to make sure you aren't overriding this elsewhere. – BMDan May 2 '11 at 4:27
I thought the same but the docs seem to point to text/plain as the default, see edit. – Eduardo Ivanec May 2 '11 at 10:43
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.