5

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.

Quentin Skousen
  • 1,035
  • 1
  • 18
  • 30

2 Answers2

5

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>
rekire
  • 47,260
  • 30
  • 167
  • 264
4

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.

Quentin Skousen
  • 1,035
  • 1
  • 18
  • 30
  • 1
    I have since moved on from this job (whew!), but I believe there was some (probably misguided) reason to handle the files through PHP. I wanted to leave this question and answer here in case someone else runs into the same issue. Check and triple check your `.htaccess` files! And remember that there can be multiple `.htaccess` files affecting the same request. – Quentin Skousen Oct 28 '15 at 15:11
  • 1
    The usual reason to pass file serving through PHP is to mediate access control. – fooquency May 06 '20 at 16:36