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'm trying to figure out why I can set a string literal in httpd.conf using SetEnv:

SetEnvIf anothertest ^$ something=sometext

But I can't assign the contents of another variable:

SetEnvIf anothertest ^$ something=$QUERY_STRING

The second one results in $QUERY_STRING instead of dereferencing the variable.


The above code was an attempt at troubleshooting an issue I'm having. The ultimate goal is to get the SetEnvIf working so that I can set multiple domains with Access-Control-Allow-Origin. I'm trying to set it for domain https://localhost:8443 and Below is the code that I currently have which isn't working.

<ifModule mod_headers.c>
SetEnvIf Origin "^http(s)?://(.+\.)?(localhost:8443|10\.1\.40\.75:8443)$" origin_is=$0
Header always set Access-Control-Allow-Origin %{origin_is}e env=origin_is
Header set Access-Control-Allow-Credentials true
share|improve this question

It's because Apache doesn't support that in the mod_setenvif module:

If you let us know what you're trying to achieve, perhaps one of us can suggest an alternative solution?

share|improve this answer
Updated the original question... – opike Apr 13 '13 at 20:54

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.