Apache ignoring mime-type

Quentin Skousen picture Quentin Skousen · Aug 21, 2013 · Viewed 13.2k times · Source

I have a page that is using JWPlayer to serve a video in a variety of format choices (mp4, m4v, ogv, webm). However, when accessing the page from Firefox (23.0.1) or with PHP curl, Apache is returning a header indicating the content-type as text/plain. Firefox (and newer IE versions, unless in compatibility mode) will not play the video. I have tried adding the mime types in mime.types, httpd.conf, and in an .htaccess file in the directory.

mime.types

video/mp4   mp4 m4v
video/ogg   ogv
video/webm  webm

httpd.conf

AddType video/mp4 mp4 m4v
AddType video/ogg ogv
AddType video/webm webm

.htaccess

AddType video/mp4 mp4 m4v
AddType video/ogg ogv
AddType video/webm webm

I have tried with and without the dot in front of the extensions (which as I understand should work either way). I have restarted Apache. I have verified that I am editing the right configuration files. Still Apache continues to return the text/plain type. Where have I gone wrong?

UPDATE: Tried FilesMatch and ForceType directive as suggested by rekire in httpd.conf, virtualhost, and .htaccess. Tried renaming files and changing links to match in case of middleman caching. Going straight to the URL downloads the video and allows to play it in desktop player normally.

Answer

rekire picture rekire · Aug 21, 2013

In the official documentation for AddType of mod_mime are the file extensions listed with a leading dot so try this:

AddType video/mp4 .mp4 .m4v
AddType video/ogg .ogv
AddType video/webm .webm

Or try ForceType together with FilesMatch:

<FilesMatch "\.(mp4|m4v)$">
    ForceType video/mp4
</FilesMatch>