The title of this post is slightly misleading, since the Content-Disposition header cannot be set directly using mod_rewrite. As I understand it, there are a set of headers that mod_rewrite understands, and Content-Disposition is not one of them.
So, to prompt the user to save cappuccino.jar instead of "latest", I used an interesting combination of mod_rewrite and mod_headers. Specifically, I used mod_rewrite to internally redirect any requests to .../cappuccino/latest to the latest cappuccino Jar file available on my server. Second, I used mod_headers to add a Content-Disposition header to any request ending with ../cappuccino/latest, which forces the browser/client to interpret the file as "cappuccino.jar" and not "latest". Here's the configuration from my Apache httpd.conf file:
## Internally redirect for Cappuccino
RewriteRule ^/cappuccino/latest /cappuccino/dist/cappuccino-v0.1.jar [L]
SetEnvIfNoCase Request_URI cappuccino\/latest$ cappuccino-latest
Header set Content-Disposition \
"attachment; filename=cappuccino.jar" env=cappuccino-latest
With this configuration, Apache will set the Content-Disposition header on each request for http://mark.koli.ch/cappuccino/latest. Using a tool like HttpFox, you can prove to yourself that this works as expected:
Enjoy.


Did you find this post helpful, or at least, interesting?