Quantcast
Channel: Configuration & Scripting
Viewing all articles
Browse latest Browse all 780

Correct MIME-Type for IIS URL Rewrite

$
0
0

I have this rewrite rule:

<rule name="Test" patternSyntax="ECMAScript" stopProcessing="true"><match url="^[A-F0-9]{40}$" negate="true"/><conditions trackAllCaptures="true"><add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /><add input="{QUERY_STRING}" pattern="h=([A-F0-9]{40})" /></conditions><action type="Rewrite" url="{C:1}" appendQueryString="false"/></rule>

It lets me go to URLs of <anything>?h=<SHA1hash>, and it serves up the file <SHA1hash>. So far, so good. The problem is that <anything>'s file extension is ignored, so for instance if I try to do test.mp4?h=xxx, I get a MIME-Type of application/octet-stream. Just to make sure I'm not suffering from some random issue, I tried doing this:

<staticContent><remove fileExtension=".mp4" /><mimeMap fileExtension=".mp4" mimeType="video/mp4" /></staticContent>

It made no difference. It occurs to me that it's using whatever the MIME-type of the actual file rather than my virtual file. This, however, is exactly the opposite of what I'm trying to achieve.

Is there any way to get IIS to base the MIME-Type off of my virtual file names instead?


Viewing all articles
Browse latest Browse all 780

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>