Apache - Send Response Header Based On MIME

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Apache - Send Response Header Based On MIME

Post by Ollie Saunders »

I want to send a "Content-Disposition: attachment" response header if the file is a video; if it has a MIME of video/*. I can't see to find the appropriate Apache directive (using Apache 2.0.x) for this.

This directive:

Code: Select all

Header set "Content-Disposition" "attachment"
Sends the header fine but what can I use for the conditionality? <FileMatch> would work but isn't particularly nice.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

Would http://httpd.apache.org/docs/2.2/mod/core.html#addoutputfilterbytype
be in use?

PS: Well, i don't think it is going to work on Apache < 2.1.+
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

PS: Well, i don't think it is going to work on Apache < 2.1.+
I'm 2.0.55 and this is available in 2.0.33 so we're good except for the fact that I don't think it's going to do what I want; unless I can define a filter that sends that header, but considering one example of a filter is deflate, I don't think filters will be able to do that.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

Hm, maybe using mod_ext_filter could be a solution?
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

I'm confused. How's that going to help?
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

Indeed, I'm not sure it will help, but the flow diagram suggests that you can manually add headers to response contents. I've never tried it but may be it is an option for you :)

Also, I think that ExtFilterDefine Directive would be useful.
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply