Aug 10, 2011
tom

How can I make all unrecognized file types as binary in Apache2?

Question

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?

Answer

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

Related posts:

  1. difference between mime types and extension filtering on IIS?
  2. Set binary registry setting through GPO
  3. What ‘LockFile’ is for in Apache2?
  4. Why does Linux report the following as a binary file?
  5. in an SSI include, can the file being included be redirected in an .htaccess file

Leave a comment