Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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: 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"

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
up vote 0 down vote accepted

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


to enclose it in quotes. sigh.

share|improve this answer

Your Answer


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.