Apache ignoring mime-type

时光总嘲笑我的痴心妄想 提交于 2019-12-23 12:49:10

问题


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.


回答1:


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>



回答2:


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.



来源:https://stackoverflow.com/questions/18366816/apache-ignoring-mime-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!