Forum Moderators: phranque
So, I need the currently requested filename in an environment varoable so I can insert it into the header:
<Location /files>
SetEnv FILENAME filename # <-- need the actual filename here!
Header set Content-Disposition "attachment; filename=%{FILENAME}e"
</Location>
Is this possible?
Martin
Header set Content-Disposition "attachment; filename=%{REQUEST_FILENAME}"
You might want to take a look through the list of cgi variables if that one does not suit your needs.
Jim
SetEnvIf REQUEST_URI "/([^/]+)$" FILENAME=$1
Header set Content-Disposition "attachment; filename=\"%{FILENAME}e\"" env=FILENAME
It works fine, but unfortunately it didn't solve the problem I had with IE. The problem with IE was that if you clicked "Open", it would download the file but then delete it right before launching the external application (adobe pdf in this case)
This happened because I used mod_rewrite for mass vhosts:
UseCanonicalName Off
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)*(.+)$
RewriteRule ^/(.*)$ /var/www/vhosts/%2/$1
I found a few workarounds here:
[iosart.com...]
Now I just use SERVER_NAME instead of HTTP_HOST, which works fine if UseCanonicalName is off. This way mod_rewrite won't understand that you're actually using the "Host" request header and won't add that "Vary: Host" header:
UseCanonicalName Off
RewriteEngine On
RewriteCond %{SERVER_NAME} ^(www.)*(.+)$
RewriteRule ^/(.*)$ /var/www/vhosts/%2/$1
Another solution is to simply remove the Vary response header with mod_headers.
Martin