Have Apache Force File Downloads

Published on May 1, 2009, 9:27 a.m.

apache django web

I have a Django app that lets users upload files. Any kind of file. It's nice that Apache will let me force file downloads based on the files extension.
<LocationMatch "\.(gz|tar|pdf|docx|doc|xls|xlsx|bz2|zip)$">
SetHandler None
Header set Content-Disposition attachment

So, in my HTML/templates: all I have to do is this:
<a href="SomFile.docx">Some File</a>
comments powered by Disqus