Web-server – Issue setting environment variable in apache httpd.conf

apache-2.2httpweb-server

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.

Update:

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 https://10.1.40.75:8443. 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
</ifModule>

Best Answer

It's because Apache doesn't support that in the mod_setenvif module: http://httpd.apache.org/docs/2.2/mod/mod_setenvif.html

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