I've got a rewrite rule inshtaccess

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

having a request URI like: /123.fid/myfile.webm

How do i pressure the mime type to: video/webm using .htaccess such as the rule above?

Things I have attempted already, to include on the top from the .htaccess file with no success:

AddType video/webm .webm


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

I personally use apaches mime_miracle module to find information about mime kind of .fid files, but this does not affect webm files. I am presuming it is the RewriteRule that is leading to issues with the file type, and I have to search for webm within the request uri in some way.

Basically do: AddType video/webm .fid the right mime type is distributed - but this breaks every other extendable saved insfid. Using .fid is really a design requirement and can't change.


I additionally attempted:

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


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

with similar result. The mime type offered is text/plain. Could this be mime_miracle module interfiering?

I additionally tried to add: DefaultType video/webm which works. This is actually the nearest factor to some solution presently, as mime_miracle module appears to obtain the correct mime types to transmit, however i don't find this to become a particularly elegant solution

*Edit2: AddType video/webm .fid IS working - how do i conditionally do AddType according to request uri?

You should use the T-flag inside a RewriteRule:

RewriteRule someRegEx$ - [T=video/webm]


If you're delivering the information having a script (a fantasy files) then your script must send the right headers, for instance with PHP (before every other output):

header("Content-type: video/webm");

Just in case of real files you should use content-settlement (rather than rewrite) and:

AddType video/webm .fid


Regrettably I am not near apache, but this may worth an attempt:

RewriteCond %{REQUEST_URI} \.webm$
RewriteRule (.*) $1 [E=is_webm:true]

Header set Content-Type video/webm env=is_webm

Not able to get this operate in Apache, I threw in the towel and gone to live in nginx rather. I first got it to operate in nginx using:

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

It labored for me personally, after i added the next lines to my .htaccess file:

<IfModule mod_rewrite.c>
  AddType video/ogg .ogv
  AddType video/webm .webm
  AddType video/mp4 .mp4