Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am attempting to use the IHS 7.0/apache 2.2 SetEnvIf directive to set the filename of a downloaded file based on a url parameter. I think I am pretty close, however if there is a space (encoded or otherwise) in the filename - it fails.

example url:

http://site.com/path/to/filename.ext/file-title=Nice File Name.ext?file-type=foo

apache config:

SetEnvIf Request_URI "^.*file-title\=(.*)\??.*$" FILENAME=$1
Header unset "Content-Disposition"
Header add "Content-Disposition" "attachment; filename=%{FILENAME}e"
UnsetEnv FILENAME

An application will specify what is now showing up as "Nice File Title.ext" in the example. This all works great if there are no spaces, however - if there is a space the filename to download will just show up as "Nice". There may or may not be a second set of parameters in the query string (?file-type, etc)

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

ok - so leaving the regex alone and changing the Header add did the trick.

filename=\"%{FILENAME}e\""

to enclose it in quotes. sigh.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.