I would like to get the value of a environment variable and assign it to another variable in Apache.
For example, get the value of $_SERVER['REMOTE_ADDR']
assign it to $_SERVER['USER-IP']
and override $_SERVER['REMOTE_ADDR']
to 127.0.0.1
I am stuck on getting the value of REMOTE_ADDR
<IfDefine !USER-IP>
SetEnv USER-IP %{REMOTE_ADDR}
SetEnv REMOTE_ADDR '127.0.0.1'
</IfDefine>
Best Answer
Looking at the docs, the
$_SERVER['REMOTE_ADDR']
var is not strictly an environment variable, but a cgi request meta-variable provided by the web server to the cgi context; http://www.faqs.org/rfcs/rfc3875.htmlThe apache docs indicate that these variables cannot be overriden using the standard
SetEnv
style directivesSo I think it's unlikely you can set those values easily from apache conf
Setting environment variables
(from existing server variables)