How to send Content-Disposition headers in apache for files?
Posted
by Rory McCann
on Server Fault
See other posts from Server Fault
or by Rory McCann
Published on 2010-01-12T16:12:35Z
Indexed on
2010/03/16
18:41 UTC
Read the original article
Hit count: 401
I have a directory of text files that I'm serving out with apache 2. Normally when I (or any user) access the files they see them in their browser. I want to 'force'* the web browser to pop up a 'Save as' dialog box. I know this is possible to do with the Content-Disposition
headers (more info).
Is there some way to turn that on for each file?
Ideally I'd like something like this:
<Directory textfiles>
AutoAddContentDispositionHeaders On
</Directory>
And then apache would set the correct content disposition header, including using the same filename.
Something like this might be possible with the apache Header
directive.
Bonus points if it's included by standing in apache in debian.
I could do a simple PHP wrapper script that takes in a filename
argument, makes the call to header(...)
and then prints the file, but then i have to validdate input etc. that's work I'm trying to avoid.
* I know you can't actually force things when it comes to the web
© Server Fault or respective owner