阿帕奇忽略了MIME类型 [英] Apache ignoring mime-type

查看:124
本文介绍了阿帕奇忽略了MIME类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面正在使用JWPlayer播放各种格式的视频(mp4,m4v,ogv,webm).但是,从Firefox(23.0.1)或使用PHP curl访问该页面时,Apache返回的标头表示content-typetext/plain. Firefox(及更高版本的IE,除非处于兼容模式下)将无法播放视频.我尝试在mime.typeshttpd.conf和目录的.htaccess文件中添加mime类型.

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

我尝试了在扩展名的前面有无点(据我所知应该以任何一种方式工作).我已经重新启动了Apache.我已经验证我正在编辑正确的配置文件. Apache仍然继续返回text/plain类型.我在哪里弄错了?

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?

更新:根据httpd.conf,virtualhost和.htaccess中的rekire建议尝试了FilesMatchForceType指令.尝试重命名文件并更改链接以匹配中间人缓存.直接转到URL即可下载视频,并可以在桌面播放器中正常播放.

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.

推荐答案

两年后回答我自己的问题.事实证明,这是一个无法从我在问题中提供的信息确定的问题,而这是一个相对简单的问题.有一个.htaccess文件将所有请求(无论是否存在现有资源文件)路由到PHP文件,然后该PHP文件本身处理所有文件请求,包括返回MIME类型,有效地绕过了我尝试做的所有处理在Apache中.

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.

这篇关于阿帕奇忽略了MIME类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆