A MIME type for .php files
While setting some svn properties at work, we wondered about the correct MIME type for .php files.
Looking around in the various magic MIME type detection lists on our unix machines and the official IANA MIME type list . The options we came up with were:
MIME type rules
Since there is no official MIME type registered at IANA, only an extension type (x- prefixed) can be used - which means that text/php and application/php are not suitable:
Any unregistered file type should be listed with a preceding x-, as in application/x-foo (RFC2045 5.1), or a x., as in application/x.foo (RFC4288 4.3). Any non x-prefixed type should be registered with IANA and listed at the above address. Any other behavior is a MIME standards violation!
Ubuntu's magic MIME database - used by the file command - spits out text/x-php:$ file -i update-file.php update-file.php: text/x-php; charset=us-ascii
Debian's mime-support package, also shipped by Ubuntu, lists application/x-httpd-php for .php and application/x-httpd-php-source for .phps files in /etc/mime.types. This two types are - in my eyes - more for internal Apache/webserver use since PHP is not only usable within a web server.
Use of the "text" top-level type for this kind of content is known to be problematic.
- but fails to state why that is so. I guess this is because security problems arise since browsers display every text/ MIME type as html.
Looking at the officially assigned text/ types makes clear that there is not a single programming language source file type in the club. (html is, as the name implies, a markup and not a programming language - which is why text/html does not count .)
Putting programming languages under the application group has statistical significance and is also backed by previous IANA decisions. So it seems it's inevitable to use application/x-php as MIME type for .php files.