Hi, I've got a django webapp for serving dynamic content and a static/cgi webapp for static content. I'd like to configure the static app to force the download of pdf and mp3 files instead of allowing the browser to automatically "handle" them.
This site suggests doing this by using the FilesMatch directive in apache and changing the mime type to octet stream. http://www.thingy-ma-jig.co.uk/blog/06-08-2007/force-a-pdf-to-download However, I've tried this in the http.conf file of my django/apache server as well as in a .htaccess file of my static webapp with no luck. Does anyone have any suggestions on how to accomplish this? Thanks, Scott asked 01 Jul '11, 19:36 seversol |
The directives should work within an .htaccess file if your media app is 'Static/Cgi/PHP" type. Does this issue occur in more than one browser? What was the exact code you pasted into the .htaccess file? answered 01 Jul '11, 19:53 johns This is what I tried in .htaccess at the root of the ~/webapps/htdocs dir. <filesmatch "\.(?i:pdf)$"=""> ForceType application/octet-stream Header set Content-Disposition attachment </filesmatch> I also tried similar lines in the http.conf file. I also added the following line in http.conf LoadModule headers_module modules/mod_headers.so I have a feeling I don't really understand how the servers processes are controlled. I noticed that even when I shutdown my django/apache server it had no effect on my static/cgi server. I guess that's probably an apache process that's shared between many users? Thanks for the feedback!
(01 Jul '11, 22:51)
seversol
hmm ... that ="" doesn't appear in the regex in my file ...
(01 Jul '11, 22:55)
seversol
To get a better idea of how the server is set up you can use this image,
Could you possibly provide the URL this is occurring at so we can take a look at it directly? You may also submit a support ticket and we can look directly.
(01 Jul '11, 23:24)
johns
Thanks, I did submit a support ticket and here was the solution that ended up working for me. The following was added to .htaccess in the root of my static app: <filesmatch "\.(pdf|mp3)$"=""> AddType application/octet-stream .pdf AddType application/octet-stream .mp3 </filesmatch> ... again the ="" does not appear in the first line ( ...(pdf|mp3)$">) as I pasted it in. I'm not sure why the forum app is interpreting it that way. Thanks for the help!
(03 Jul '11, 16:16)
seversol
|
I just had this same problem and the final solution didn't work. I had to use
answered 24 Nov '11, 16:00 elpargo |