根据请求URI使用的.htaccess力的视频/ W​​EBM MIME类型 [英] Force video/webm mime type using .htaccess based on request uri

查看:225
本文介绍了根据请求URI使用的.htaccess力的视频/ W​​EBM MIME类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在.htaccess重写规则

I have a rewrite rule in .htaccess

RewriteRule   (.+?\.fid)/ /$1 [L]

与请求的URI,如: /123.fid/myfile.webm

我怎么能强制MIME类型:视频/ W​​EBM 使用的.htaccess包括上面的规则

How can I force the mime type to: video/webm using .htaccess including the rule above?

我已经尝试已经,增加对.htaccess文件的TOP没有成功:

What I have attempted already, to add on TOP of the .htaccess file without success:

AddType video/webm .webm

<FilesMatch  "\.webm$">
  ForceType video/webm
</FilesMatch>

我用阿帕奇mime_magic模块查找的.f​​id文件的MIME类型,但是这并不适用于WEBM文件。我假定这是这是造成问题的文件类型的重写规则,我需要寻找WEBM在请求URI不知。

I use apaches mime_magic module to look up mime type of .fid files, but this doesn't apply to webm files. I'm assuming it's the RewriteRule which is causing problems with the file type, and I need to look for webm in the request uri somehow.

如果我这样做:将AddType视频/ W​​EBM .fid 正确的MIME类型发送 - 但是这打破了存储在.fid任何其他文件格式。使用.fid是一家集设计要求,不能更改。

If I do: AddType video/webm .fid the correct mime type is sent - but this breaks any other file format stored in .fid. Using .fid is a design requirement and cannot change.

*的编辑:

我也尝试:

RewriteCond %{REQUEST_URI} \.webm$
RewriteRule .* - [T=video/webm]

RewriteRule \.webm$ - [T=video/webm]

具有相同的结果。服务过的MIME类型文本/纯。难道这是mime_magic模块interfiering?

with the same result. The mime type served is text/plain. Could this be mime_magic module interfiering?

我也尝试添加: DefaultType的视频/ W​​EBM 它的工作原理。这是最接近的解决方案目前,作为mime_magic模块似乎找到了正确的MIME类型来送,但我不觉得这是一个特别完美的解决方案。

I also attempted to add: DefaultType video/webm which works. This is the closest thing to a solution currently, as mime_magic module seems to find the correct mime types to send, but I don't find this to be a particularly elegant solution

* EDIT2 :<?code>将AddType视频/ W​​EBM .fid 是工作 - 我该怎么做有条件地将AddType基于请求URI

*Edit2: AddType video/webm .fid IS working - how can I conditionally do AddType based on request uri?

推荐答案

无法获取这在Apache的工作,我放弃了,搬到了nginx的代替。我得到了它在使用nginx的工作:

Unable to get this to work in Apache, I gave up and moved to nginx instead. I got it to work in nginx using:

location ~\.webm$ {
  add_header Content-Type video/webm;
  rewrite  (.+?\.fid)/ /$1  break;
}

这篇关于根据请求URI使用的.htaccess力的视频/ W​​EBM MIME类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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