Can I make Apache or IIS add a specific header if a certain query string is present?
I want every URL with "download=1" in the query string to be served with Content-Disposition: attachment
.
Weird question title because originally this was about Apache only, but now I've added IIS too.
mod_rewrite
withmod_headers
make this possible as follows:Haven't tested this with anything containing non-ASCII or spaces. Those will probably end up showing in the file name URL-escaped, i.e. "%20" etc.Edit: Special characters should work just fine.
I had to do the same on IIS 7.5, so here's the way to do it: place the following XML into a site's
<system.webServer><rewrite> ...
section:(obviously if you already have an
<outboundRules>
element, place only the rule inside the existing element)