Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache ignoring mime-type

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.

like image 328
Quentin Skousen Avatar asked Jan 12 '23 14:01

Quentin Skousen


2 Answers

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>
like image 102
rekire Avatar answered Jan 22 '23 01:01

rekire


Answering my own question, over 2 years later. It turned out to be an issue that was not determinable from the information I gave in the question, and a relatively simple problem. There was an .htaccess file that was routing ALL requests - existing resource files or not - to a PHP file, which was then handling all file requests itself, including returning a MIME type, effectively bypassing all of the handling I was attempting to do in Apache.

like image 32
Quentin Skousen Avatar answered Jan 22 '23 01:01

Quentin Skousen