ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding<!DOCTYPE manualpage SYSTEM "/style/manualpage.dtd">
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding<?xml-stylesheet type="text/xsl" href="/style/manual.en.xsl"?>
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding<!-- $LastChangedRevision$ -->
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding Licensed to the Apache Software Foundation (ASF) under one or more
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding contributor license agreements. See the NOTICE file distributed with
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding this work for additional information regarding copyright ownership.
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding The ASF licenses this file to You under the Apache License, Version 2.0
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding (the "License"); you may not use this file except in compliance with
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding the License. You may obtain a copy of the License at
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding Unless required by applicable law or agreed to in writing, software
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding distributed under the License is distributed on an "AS IS" BASIS,
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding See the License for the specific language governing permissions and
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding limitations under the License.
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding <p>There are two kinds of environment variables that affect
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding the Apache HTTP Server.</p>
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding <p>First, there are the environment variables controlled by
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding the underlying operating system. These are set before the
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding server starts. They can be used in expansions in configuration
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding files, and can optionally be passed to CGI scripts and SSI
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding using the PassEnv directive.</p>
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding <p>Second, the Apache HTTP Server provides a mechanism for storing
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding information in named variables that are also called <em>environment
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding variables</em>. This information can be used to control various
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding operations such as logging or access control. The variables are
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding also used as a mechanism to communicate with external programs
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding such as CGI scripts. This document discusses different ways to
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding manipulate and use these variables.</p>
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding <p>Although these variables are referred to as <em>environment
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding variables</em>, they are not the same as the environment
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding variables controlled by the underlying operating system.
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding Instead, these variables are stored and manipulated in an
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding internal Apache structure. They only become actual operating
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding system environment variables when they are provided to CGI
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding scripts and Server Side Include scripts. If you wish to
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding manipulate the operating system environment under which the
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding server itself runs, you must use the standard environment
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding manipulation mechanisms provided by your operating system
c6e3de48da56d5a2d6298585b895cf75e3ffada2ben <modulelist>
6e8fa9b44c6d5f5b3ac9dab52c4734259bcd8335coar </modulelist>
c6e3de48da56d5a2d6298585b895cf75e3ffada2ben <directivelist>
6e8fa9b44c6d5f5b3ac9dab52c4734259bcd8335coar <directive module="mod_setenvif">BrowserMatch</directive>
c6e3de48da56d5a2d6298585b895cf75e3ffada2ben <directive module="mod_setenvif">BrowserMatchNoCase</directive>
6e8fa9b44c6d5f5b3ac9dab52c4734259bcd8335coar <directive module="mod_rewrite">RewriteRule</directive>
6e8fa9b44c6d5f5b3ac9dab52c4734259bcd8335coar <directive module="mod_setenvif">SetEnvIfNoCase</directive>
c6e3de48da56d5a2d6298585b895cf75e3ffada2ben </directivelist>
6e8fa9b44c6d5f5b3ac9dab52c4734259bcd8335coar </related>
6e8fa9b44c6d5f5b3ac9dab52c4734259bcd8335coar <p>The most basic way to set an environment variable in Apache
c6e3de48da56d5a2d6298585b895cf75e3ffada2ben >SetEnv</directive> directive. Variables may also be passed from
c6e3de48da56d5a2d6298585b895cf75e3ffada2ben the environment of the shell which started the server using the
6e8fa9b44c6d5f5b3ac9dab52c4734259bcd8335coar <directive module="mod_env">PassEnv</directive> directive.</p>
c6e3de48da56d5a2d6298585b895cf75e3ffada2ben </section>
6e8fa9b44c6d5f5b3ac9dab52c4734259bcd8335coar <p>For additional flexibility, the directives provided by
c6e3de48da56d5a2d6298585b895cf75e3ffada2ben <module>mod_setenvif</module> allow environment variables to be set
6e8fa9b44c6d5f5b3ac9dab52c4734259bcd8335coar on a per-request basis, conditional on characteristics of particular
6e8fa9b44c6d5f5b3ac9dab52c4734259bcd8335coar requests. For example, a variable could be set only when a
6e8fa9b44c6d5f5b3ac9dab52c4734259bcd8335coar specific browser (User-Agent) is making a request, or only when
c6e3de48da56d5a2d6298585b895cf75e3ffada2ben a specific Referer [sic] header is found. Even more flexibility
6e8fa9b44c6d5f5b3ac9dab52c4734259bcd8335coar is available through the <module>mod_rewrite</module>'s <directive
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm module="mod_rewrite">RewriteRule</directive> which uses the
ed544bb072e2f73ea4e7ef5191650dd487d02b84rbb <code>[E=...]</code> option to set environment variables.</p>
6e8fa9b44c6d5f5b3ac9dab52c4734259bcd8335coar </section>
ed544bb072e2f73ea4e7ef5191650dd487d02b84rbb <p>Finally, <module>mod_unique_id</module> sets the environment
6e8fa9b44c6d5f5b3ac9dab52c4734259bcd8335coar variable <code>UNIQUE_ID</code> for each request to a value which is
c6e3de48da56d5a2d6298585b895cf75e3ffada2ben guaranteed to be unique across "all" requests under very
6e8fa9b44c6d5f5b3ac9dab52c4734259bcd8335coar specific conditions.</p>
6e8fa9b44c6d5f5b3ac9dab52c4734259bcd8335coar </section>
ebe70c2684539a5fb2d899241d1601710dfa38a4trawick <p>In addition to all environment variables set within the
e4afb803ff9a51f9ec7969f232b7fd4a4e94d5d4rbb Apache configuration and passed from the shell, CGI scripts and
e4afb803ff9a51f9ec7969f232b7fd4a4e94d5d4rbb SSI pages are provided with a set of environment variables
ebe70c2684539a5fb2d899241d1601710dfa38a4trawick containing meta-information about the request as required by
2bf9d434b718368d72c1be69ede336cf19162902ben </section>
3d96ee83babeec32482c9082c9426340cee8c44dwrowe <li>It is not possible to override or change the standard CGI
c6e3de48da56d5a2d6298585b895cf75e3ffada2ben variables using the environment manipulation directives.</li>
c6e3de48da56d5a2d6298585b895cf75e3ffada2ben CGI scripts, the environment will be cleaned down to a set of
c6e3de48da56d5a2d6298585b895cf75e3ffada2ben <em>safe</em> variables before CGI scripts are launched. The
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm list of <em>safe</em> variables is defined at compile-time in
SetEnvIfNoCase ^Accept.Encoding$ ^(.*)$ fix_accept_encoding=$1
httpd.conf to deal with known client problems. Since the affected clients
# The first directive disables keepalive for Netscape 2.x and browsers that
SetEnvIf Referer "^http://www\.example\.com/" local_referal