env.html.en revision 4c47688d73a9a5ef2735cd84f334b8eb814c74f0
842ae4bd224140319ae7feec1872b93dfd491143fielding<?xml version="1.0" encoding="ISO-8859-1"?>
842ae4bd224140319ae7feec1872b93dfd491143fielding<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
842ae4bd224140319ae7feec1872b93dfd491143fielding<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
842ae4bd224140319ae7feec1872b93dfd491143fielding XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
842ae4bd224140319ae7feec1872b93dfd491143fielding This file is generated from xml source: DO NOT EDIT
842ae4bd224140319ae7feec1872b93dfd491143fielding XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse -->
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd<title>Environment Variables in Apache - Apache HTTP Server</title>
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse<link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd<link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd<link href="/style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd<link href="/images/favicon.ico" rel="shortcut icon" /></head>
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd<body id="manual-page"><div id="page-header">
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="/faq/">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p>
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd<p class="apache">Apache HTTP Server Version 2.3</p>
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd<img alt="" src="/images/feather.gif" /></div>
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd<div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="/images/left.gif" /></a></div>
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd<div id="path">
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd<a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="./">Version 2.3</a></div><div id="page-content"><div id="preamble"><h1>Environment Variables in Apache</h1>
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd<div class="toplang">
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd<p><span>Available Languages: </span><a href="/en/env.html" title="English">&nbsp;en&nbsp;</a> |
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd<a href="/fr/env.html" hreflang="fr" rel="alternate" title="Fran�ais">&nbsp;fr&nbsp;</a> |
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd<a href="/ja/env.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd<a href="/ko/env.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a> |
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse<a href="/tr/env.html" hreflang="tr" rel="alternate" title="T�rk�e">&nbsp;tr&nbsp;</a></p>
6ace32dacb8313226eb9019275d0e4fa45a15148rse</div>
70535d6421eb979ac79d8f49d31cd94d75dd8b2fjorton
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse <p>There are two kinds of environment variables that affect
a943533fd4d91d114af622731a405407990c4fb1rse the Apache HTTP Server.</p>
67139e2d50d1e11558d87f7042f61cb04bb0d1d2jim
a943533fd4d91d114af622731a405407990c4fb1rse <p>First, there are the environment variables controlled by
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse the underlying operating system. These are set before the
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse server starts. They can be used in expansions in configuration
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse files, and can optionally be passed to CGI scripts and SSI
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse using the PassEnv directive.</p>
7933d4a963def02417113b6798d87a36395053b0rse
7933d4a963def02417113b6798d87a36395053b0rse <p>Second, the Apache HTTP Server provides a mechanism for storing
71c00f988beb28388702e14cb7fe06f08bd792bbdougm information in named variables that are also called <em>environment
71c00f988beb28388702e14cb7fe06f08bd792bbdougm variables</em>. This information can be used to control various
71c00f988beb28388702e14cb7fe06f08bd792bbdougm operations such as logging or access control. The variables are
7933d4a963def02417113b6798d87a36395053b0rse also used as a mechanism to communicate with external programs
71c00f988beb28388702e14cb7fe06f08bd792bbdougm such as CGI scripts. This document discusses different ways to
71c00f988beb28388702e14cb7fe06f08bd792bbdougm manipulate and use these variables.</p>
71c00f988beb28388702e14cb7fe06f08bd792bbdougm
7933d4a963def02417113b6798d87a36395053b0rse <p>Although these variables are referred to as <em>environment
71c00f988beb28388702e14cb7fe06f08bd792bbdougm variables</em>, they are not the same as the environment
71c00f988beb28388702e14cb7fe06f08bd792bbdougm variables controlled by the underlying operating system.
71c00f988beb28388702e14cb7fe06f08bd792bbdougm Instead, these variables are stored and manipulated in an
7933d4a963def02417113b6798d87a36395053b0rse internal Apache structure. They only become actual operating
7933d4a963def02417113b6798d87a36395053b0rse system environment variables when they are provided to CGI
d1bb6e2664788e0437acc18e877562c9a796d7cerse scripts and Server Side Include scripts. If you wish to
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse manipulate the operating system environment under which the
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse server itself runs, you must use the standard environment
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse manipulation mechanisms provided by your operating system
c95d39bd1b86b856ca72485516e7b2e61008fe96wrowe shell.</p>
7933d4a963def02417113b6798d87a36395053b0rse </div>
7933d4a963def02417113b6798d87a36395053b0rse<div id="quickview"><ul id="toc"><li><img alt="" src="/images/down.gif" /> <a href="#setting">Setting Environment Variables</a></li>
71c00f988beb28388702e14cb7fe06f08bd792bbdougm<li><img alt="" src="/images/down.gif" /> <a href="#using">Using Environment Variables</a></li>
71c00f988beb28388702e14cb7fe06f08bd792bbdougm<li><img alt="" src="/images/down.gif" /> <a href="#special">Special Purpose Environment Variables</a></li>
7933d4a963def02417113b6798d87a36395053b0rse<li><img alt="" src="/images/down.gif" /> <a href="#examples">Examples</a></li>
7933d4a963def02417113b6798d87a36395053b0rse</ul></div>
42167da203d969a1402cf7ce09c14586c04af1dfjim<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
53c239bee62c6d55b5ddfba5d99376d4c8de924ejwoolley<div class="section">
7933d4a963def02417113b6798d87a36395053b0rse<h2><a name="setting" id="setting">Setting Environment Variables</a></h2>
7933d4a963def02417113b6798d87a36395053b0rse
7933d4a963def02417113b6798d87a36395053b0rse <table class="related"><tr><th>Related Modules</th><th>Related Directives</th></tr><tr><td><ul><li><code class="module"><a href="/mod/mod_cache.html">mod_cache</a></code></li><li><code class="module"><a href="/mod/mod_env.html">mod_env</a></code></li><li><code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code></li><li><code class="module"><a href="/mod/mod_setenvif.html">mod_setenvif</a></code></li><li><code class="module"><a href="/mod/mod_unique_id.html">mod_unique_id</a></code></li></ul></td><td><ul><li><code class="directive"><a href="/mod/mod_setenvif.html#browsermatch">BrowserMatch</a></code></li><li><code class="directive"><a href="/mod/mod_setenvif.html#browsermatchnocase">BrowserMatchNoCase</a></code></li><li><code class="directive"><a href="/mod/mod_env.html#passenv">PassEnv</a></code></li><li><code class="directive"><a href="/mod/mod_rewrite.html#rewriterule">RewriteRule</a></code></li><li><code class="directive"><a href="/mod/mod_env.html#setenv">SetEnv</a></code></li><li><code class="directive"><a href="/mod/mod_setenvif.html#setenvif">SetEnvIf</a></code></li><li><code class="directive"><a href="/mod/mod_setenvif.html#setenvifnocase">SetEnvIfNoCase</a></code></li><li><code class="directive"><a href="/mod/mod_env.html#unsetenv">UnsetEnv</a></code></li></ul></td></tr></table>
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse
7933d4a963def02417113b6798d87a36395053b0rse <h3><a name="basic-manipulation" id="basic-manipulation">Basic Environment Manipulation</a></h3>
7933d4a963def02417113b6798d87a36395053b0rse
7933d4a963def02417113b6798d87a36395053b0rse
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse <p>The most basic way to set an environment variable in Apache
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse is using the unconditional <code class="directive"><a href="/mod/mod_env.html#setenv">SetEnv</a></code> directive. Variables may also be passed from
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse the environment of the shell which started the server using the
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse <code class="directive"><a href="/mod/mod_env.html#passenv">PassEnv</a></code> directive.</p>
e726f34f8da08c01ee8bc90904b26196b69c8587wrowe
7933d4a963def02417113b6798d87a36395053b0rse
7933d4a963def02417113b6798d87a36395053b0rse <h3><a name="conditional" id="conditional">Conditional Per-Request Settings</a></h3>
7933d4a963def02417113b6798d87a36395053b0rse
7933d4a963def02417113b6798d87a36395053b0rse
7933d4a963def02417113b6798d87a36395053b0rse <p>For additional flexibility, the directives provided by
7933d4a963def02417113b6798d87a36395053b0rse <code class="module"><a href="/mod/mod_setenvif.html">mod_setenvif</a></code> allow environment variables to be set
7933d4a963def02417113b6798d87a36395053b0rse on a per-request basis, conditional on characteristics of particular
7933d4a963def02417113b6798d87a36395053b0rse requests. For example, a variable could be set only when a
7933d4a963def02417113b6798d87a36395053b0rse specific browser (User-Agent) is making a request, or only when
7933d4a963def02417113b6798d87a36395053b0rse a specific Referer [sic] header is found. Even more flexibility
7933d4a963def02417113b6798d87a36395053b0rse is available through the <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code>'s <code class="directive"><a href="/mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> which uses the
7933d4a963def02417113b6798d87a36395053b0rse <code>[E=...]</code> option to set environment variables.</p>
7933d4a963def02417113b6798d87a36395053b0rse
7933d4a963def02417113b6798d87a36395053b0rse
176c2742db03fcb7b7d13e6408dd967d87e542e9ben <h3><a name="unique-identifiers" id="unique-identifiers">Unique Identifiers</a></h3>
e0c3fda9f782aee1140d83fbce32672ac299f2a4ben
3a8856c9ca9e996d3a1fae2c65943c35eed97481rpluem
7933d4a963def02417113b6798d87a36395053b0rse <p>Finally, <code class="module"><a href="/mod/mod_unique_id.html">mod_unique_id</a></code> sets the environment
7933d4a963def02417113b6798d87a36395053b0rse variable <code>UNIQUE_ID</code> for each request to a value which is
7933d4a963def02417113b6798d87a36395053b0rse guaranteed to be unique across "all" requests under very
7933d4a963def02417113b6798d87a36395053b0rse specific conditions.</p>
7933d4a963def02417113b6798d87a36395053b0rse
7933d4a963def02417113b6798d87a36395053b0rse
e335319a08e12eb7daff9afa80e985dc53f652b8jorton <h3><a name="standard-cgi" id="standard-cgi">Standard CGI Variables</a></h3>
e335319a08e12eb7daff9afa80e985dc53f652b8jorton
e335319a08e12eb7daff9afa80e985dc53f652b8jorton
e335319a08e12eb7daff9afa80e985dc53f652b8jorton <p>In addition to all environment variables set within the
e335319a08e12eb7daff9afa80e985dc53f652b8jorton Apache configuration and passed from the shell, CGI scripts and
e335319a08e12eb7daff9afa80e985dc53f652b8jorton SSI pages are provided with a set of environment variables
7933d4a963def02417113b6798d87a36395053b0rse containing meta-information about the request as required by
7933d4a963def02417113b6798d87a36395053b0rse the <a href="http://www.ietf.org/rfc/rfc3875">CGI
7933d4a963def02417113b6798d87a36395053b0rse specification</a>.</p>
7933d4a963def02417113b6798d87a36395053b0rse
7933d4a963def02417113b6798d87a36395053b0rse
7933d4a963def02417113b6798d87a36395053b0rse <h3><a name="caveats" id="caveats">Some Caveats</a></h3>
7933d4a963def02417113b6798d87a36395053b0rse
7933d4a963def02417113b6798d87a36395053b0rse
7933d4a963def02417113b6798d87a36395053b0rse <ul>
7933d4a963def02417113b6798d87a36395053b0rse <li>It is not possible to override or change the standard CGI
7933d4a963def02417113b6798d87a36395053b0rse variables using the environment manipulation directives.</li>
7933d4a963def02417113b6798d87a36395053b0rse
7933d4a963def02417113b6798d87a36395053b0rse <li>When <code class="program"><a href="/programs/suexec.html">suexec</a></code> is used to launch
7933d4a963def02417113b6798d87a36395053b0rse CGI scripts, the environment will be cleaned down to a set of
7933d4a963def02417113b6798d87a36395053b0rse <em>safe</em> variables before CGI scripts are launched. The
7933d4a963def02417113b6798d87a36395053b0rse list of <em>safe</em> variables is defined at compile-time in
7933d4a963def02417113b6798d87a36395053b0rse <code>suexec.c</code>.</li>
7933d4a963def02417113b6798d87a36395053b0rse
7efe7de73c89c26518714a504359244d03cfbbc5jorton <li>For portability reasons, the names of environment
7efe7de73c89c26518714a504359244d03cfbbc5jorton variables may contain only letters, numbers, and the
f84d3d83a741c21154d42e0ebdec9b9b37efeedcjorton underscore character. In addition, the first character may
43c3e6a4b559b76b750c245ee95e2782c15b4296jim not be a number. Characters which do not match this
3c36b0324c8486306904c84eb0264affc45ed56cwrowe restriction will be replaced by an underscore when passed to
3c36b0324c8486306904c84eb0264affc45ed56cwrowe CGI scripts and SSI pages.</li>
3c36b0324c8486306904c84eb0264affc45ed56cwrowe
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse <li>A special case are HTTP headers which are passed to CGI
e8f95a682820a599fe41b22977010636be5c2717jim scripts and the like via environment variables (see below).
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse They are converted to uppercase and only dashes are replaced with
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse underscores; if the header contains any other (invalid) character,
cde1010d880fb6230f80c9d697842ea0b1cb79c7dougm the whole header is silently dropped. See <a href="#fixheader">
cde1010d880fb6230f80c9d697842ea0b1cb79c7dougm below</a> for a workaround.</li>
cde1010d880fb6230f80c9d697842ea0b1cb79c7dougm
7933d4a963def02417113b6798d87a36395053b0rse <li>The <code class="directive"><a href="/mod/mod_env.html#setenv">SetEnv</a></code> directive runs
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse late during request processing meaning that directives such as
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse <code class="directive"><a href="/mod/mod_setenvif.html#setenvif">SetEnvIf</a></code> and <code class="directive"><a href="/mod/mod_rewrite.html#rewritecond">RewriteCond</a></code> will not see the
7933d4a963def02417113b6798d87a36395053b0rse variables set with it.</li>
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse </ul>
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse
8fdc55d1624c714391fe1f93ebafe98ace427f4adougm </div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse<div class="section">
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse<h2><a name="using" id="using">Using Environment Variables</a></h2>
7933d4a963def02417113b6798d87a36395053b0rse
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse <table class="related"><tr><th>Related Modules</th><th>Related Directives</th></tr><tr><td><ul><li><code class="module"><a href="/mod/mod_authz_host.html">mod_authz_host</a></code></li><li><code class="module"><a href="/mod/mod_cgi.html">mod_cgi</a></code></li><li><code class="module"><a href="/mod/mod_ext_filter.html">mod_ext_filter</a></code></li><li><code class="module"><a href="/mod/mod_headers.html">mod_headers</a></code></li><li><code class="module"><a href="/mod/mod_include.html">mod_include</a></code></li><li><code class="module"><a href="/mod/mod_log_config.html">mod_log_config</a></code></li><li><code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code></li></ul></td><td><ul><li><code class="directive"><a href="/mod/mod_authz_host.html#allow">Allow</a></code></li><li><code class="directive"><a href="/mod/mod_log_config.html#customlog">CustomLog</a></code></li><li><code class="directive"><a href="/mod/mod_authz_host.html#deny">Deny</a></code></li><li><code class="directive"><a href="/mod/mod_ext_filter.html#extfilterdefine">ExtFilterDefine</a></code></li><li><code class="directive"><a href="/mod/mod_headers.html#header">Header</a></code></li><li><code class="directive"><a href="/mod/mod_log_config.html#logformat">LogFormat</a></code></li><li><code class="directive"><a href="/mod/mod_rewrite.html#rewritecond">RewriteCond</a></code></li><li><code class="directive"><a href="/mod/mod_rewrite.html#rewriterule">RewriteRule</a></code></li></ul></td></tr></table>
7933d4a963def02417113b6798d87a36395053b0rse
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse <h3><a name="cgi-scripts" id="cgi-scripts">CGI Scripts</a></h3>
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse
7933d4a963def02417113b6798d87a36395053b0rse
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse <p>One of the primary uses of environment variables is to
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse communicate information to CGI scripts. As discussed above, the
a72de14bfdbf0be9d935be9bdc2df631ca5e032bdougm environment passed to CGI scripts includes standard
a72de14bfdbf0be9d935be9bdc2df631ca5e032bdougm meta-information about the request in addition to any variables
a72de14bfdbf0be9d935be9bdc2df631ca5e032bdougm set within the Apache configuration. For more details, see the
a72de14bfdbf0be9d935be9bdc2df631ca5e032bdougm <a href="howto/cgi.html">CGI tutorial</a>.</p>
a72de14bfdbf0be9d935be9bdc2df631ca5e032bdougm
a72de14bfdbf0be9d935be9bdc2df631ca5e032bdougm
7933d4a963def02417113b6798d87a36395053b0rse <h3><a name="ssi-pages" id="ssi-pages">SSI Pages</a></h3>
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse
7933d4a963def02417113b6798d87a36395053b0rse <p>Server-parsed (SSI) documents processed by
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse <code class="module"><a href="/mod/mod_include.html">mod_include</a></code>'s
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse <code>INCLUDES</code> filter can print environment variables
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse using the <code>echo</code> element, and can use environment
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse variables in flow control elements to makes parts of a page
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse conditional on characteristics of a request. Apache also
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse provides SSI pages with the standard CGI environment variables
7933d4a963def02417113b6798d87a36395053b0rse as discussed above. For more details, see the <a href="howto/ssi.html">SSI tutorial</a>.</p>
0839d91ee551a0e19ea9577bb00976b97308dfddmartin
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse
7933d4a963def02417113b6798d87a36395053b0rse <h3><a name="access-control" id="access-control">Access Control</a></h3>
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse
7933d4a963def02417113b6798d87a36395053b0rse <p>Access to the server can be controlled based on the value of
0839d91ee551a0e19ea9577bb00976b97308dfddmartin environment variables using the <code>allow from env=</code>
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse and <code>deny from env=</code> directives. In combination with
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse <code class="directive"><a href="/mod/mod_setenvif.html#setenvif">SetEnvIf</a></code>, this
39c7699ec0799d394d3f67145d4a12ed82f587b8jorton allows for flexible control of access to the server based on
39c7699ec0799d394d3f67145d4a12ed82f587b8jorton characteristics of the client. For example, you can use these
39c7699ec0799d394d3f67145d4a12ed82f587b8jorton directives to deny access to a particular browser (User-Agent).
39c7699ec0799d394d3f67145d4a12ed82f587b8jorton </p>
39c7699ec0799d394d3f67145d4a12ed82f587b8jorton
39c7699ec0799d394d3f67145d4a12ed82f587b8jorton
39c7699ec0799d394d3f67145d4a12ed82f587b8jorton <h3><a name="logging" id="logging">Conditional Logging</a></h3>
e6e65585927961caf45d4e9e932bb1f4e9e89ca1jerenkrantz
e8f95a682820a599fe41b22977010636be5c2717jim
e6e65585927961caf45d4e9e932bb1f4e9e89ca1jerenkrantz <p>Environment variables can be logged in the access log using
e8f95a682820a599fe41b22977010636be5c2717jim the <code class="directive"><a href="/mod/mod_log_config.html#logformat">LogFormat</a></code>
e6e65585927961caf45d4e9e932bb1f4e9e89ca1jerenkrantz option <code>%e</code>. In addition, the decision on whether
e8f95a682820a599fe41b22977010636be5c2717jim or not to log requests can be made based on the status of
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse environment variables using the conditional form of the
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse <code class="directive"><a href="/mod/mod_log_config.html#customlog">CustomLog</a></code>
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse directive. In combination with <code class="directive"><a href="/mod/mod_setenvif.html#setenvif">SetEnvIf</a></code> this allows for flexible control of which
7933d4a963def02417113b6798d87a36395053b0rse requests are logged. For example, you can choose not to log
7933d4a963def02417113b6798d87a36395053b0rse requests for filenames ending in <code>gif</code>, or you can
7933d4a963def02417113b6798d87a36395053b0rse choose to only log requests from clients which are outside your
2b7078b0c4fd5b6054f6f2d4f626177844f5c6f7wrowe subnet.</p>
2b7078b0c4fd5b6054f6f2d4f626177844f5c6f7wrowe
2b7078b0c4fd5b6054f6f2d4f626177844f5c6f7wrowe
2b7078b0c4fd5b6054f6f2d4f626177844f5c6f7wrowe <h3><a name="response-headers" id="response-headers">Conditional Response Headers</a></h3>
2b7078b0c4fd5b6054f6f2d4f626177844f5c6f7wrowe
239dd0cf663713025d4451ddd465685021007d82wrowe
2b7078b0c4fd5b6054f6f2d4f626177844f5c6f7wrowe <p>The <code class="directive"><a href="/mod/mod_headers.html#header">Header</a></code>
2b7078b0c4fd5b6054f6f2d4f626177844f5c6f7wrowe directive can use the presence or
2b7078b0c4fd5b6054f6f2d4f626177844f5c6f7wrowe absence of an environment variable to determine whether or not
2b7078b0c4fd5b6054f6f2d4f626177844f5c6f7wrowe a certain HTTP header will be placed in the response to the
2b7078b0c4fd5b6054f6f2d4f626177844f5c6f7wrowe client. This allows, for example, a certain response header to
2b7078b0c4fd5b6054f6f2d4f626177844f5c6f7wrowe be sent only if a corresponding header is received in the
2b7078b0c4fd5b6054f6f2d4f626177844f5c6f7wrowe request from the client.</p>
2b7078b0c4fd5b6054f6f2d4f626177844f5c6f7wrowe
2b7078b0c4fd5b6054f6f2d4f626177844f5c6f7wrowe
2b7078b0c4fd5b6054f6f2d4f626177844f5c6f7wrowe
2b7078b0c4fd5b6054f6f2d4f626177844f5c6f7wrowe <h3><a name="external-filter" id="external-filter">External Filter Activation</a></h3>
2b7078b0c4fd5b6054f6f2d4f626177844f5c6f7wrowe
2b7078b0c4fd5b6054f6f2d4f626177844f5c6f7wrowe
239dd0cf663713025d4451ddd465685021007d82wrowe <p>External filters configured by <code class="module"><a href="/mod/mod_ext_filter.html">mod_ext_filter</a></code>
239dd0cf663713025d4451ddd465685021007d82wrowe using the <code class="directive"><a href="/mod/mod_ext_filter.html#extfilterdefine">ExtFilterDefine</a></code> directive can
2b7078b0c4fd5b6054f6f2d4f626177844f5c6f7wrowe by activated conditional on an environment variable using the
239dd0cf663713025d4451ddd465685021007d82wrowe <code>disableenv=</code> and <code>enableenv=</code> options.</p>
239dd0cf663713025d4451ddd465685021007d82wrowe
2b7078b0c4fd5b6054f6f2d4f626177844f5c6f7wrowe
56bd16e394f49423a22aa82643eb27f26db2c748jorton <h3><a name="url-rewriting" id="url-rewriting">URL Rewriting</a></h3>
56bd16e394f49423a22aa82643eb27f26db2c748jorton
56bd16e394f49423a22aa82643eb27f26db2c748jorton
56bd16e394f49423a22aa82643eb27f26db2c748jorton <p>The <code>%{ENV:<em>variable</em>}</code> form of
56bd16e394f49423a22aa82643eb27f26db2c748jorton <em>TestString</em> in the <code class="directive"><a href="/mod/mod_rewrite.html#rewritecond">RewriteCond</a></code> allows <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code>'s rewrite
e8f95a682820a599fe41b22977010636be5c2717jim engine to make decisions conditional on environment variables.
e8f95a682820a599fe41b22977010636be5c2717jim Note that the variables accessible in <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code>
2b7078b0c4fd5b6054f6f2d4f626177844f5c6f7wrowe without the <code>ENV:</code> prefix are not actually environment
2b7078b0c4fd5b6054f6f2d4f626177844f5c6f7wrowe variables. Rather, they are variables special to
2b7078b0c4fd5b6054f6f2d4f626177844f5c6f7wrowe <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> which cannot be accessed from other
239dd0cf663713025d4451ddd465685021007d82wrowe modules.</p>
2b7078b0c4fd5b6054f6f2d4f626177844f5c6f7wrowe
d1bb6e2664788e0437acc18e877562c9a796d7cerse </div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
71c00f988beb28388702e14cb7fe06f08bd792bbdougm<div class="section">
71c00f988beb28388702e14cb7fe06f08bd792bbdougm<h2><a name="special" id="special">Special Purpose Environment Variables</a></h2>
71c00f988beb28388702e14cb7fe06f08bd792bbdougm
7933d4a963def02417113b6798d87a36395053b0rse
e8f95a682820a599fe41b22977010636be5c2717jim <p>Interoperability problems have led to the introduction of
b5451913a64155af2eab4f12ecbaf16e15acafc3wrowe mechanisms to modify the way Apache behaves when talking to
b5451913a64155af2eab4f12ecbaf16e15acafc3wrowe particular clients. To make these mechanisms as flexible as
8aced0b621ea45e8621c7073b0bfbe5ea91c2329wrowe possible, they are invoked by defining environment variables,
239dd0cf663713025d4451ddd465685021007d82wrowe typically with <code class="directive"><a href="/mod/mod_setenvif.html#browsermatch">BrowserMatch</a></code>, though <code class="directive"><a href="/mod/mod_env.html#setenv">SetEnv</a></code> and <code class="directive"><a href="/mod/mod_env.html#passenv">PassEnv</a></code> could also be used, for example.</p>
b5451913a64155af2eab4f12ecbaf16e15acafc3wrowe
239dd0cf663713025d4451ddd465685021007d82wrowe <h3><a name="downgrade" id="downgrade">downgrade-1.0</a></h3>
93350a0dfa22a2c523cdcbad3357327013ecc145martin
2c038bf2465bf2150c396f4e67f68ebc5bb9e6e9wrowe
b5451913a64155af2eab4f12ecbaf16e15acafc3wrowe <p>This forces the request to be treated as a HTTP/1.0 request
b5451913a64155af2eab4f12ecbaf16e15acafc3wrowe even if it was in a later dialect.</p>
b5451913a64155af2eab4f12ecbaf16e15acafc3wrowe
239dd0cf663713025d4451ddd465685021007d82wrowe
8a5120efd60acf0323371cb30cba489723b03819jorton <h3><a name="force-gzip" id="force-gzip">force-gzip</a></h3>
e13735ceb2025ea8ed0c530093e13fe57b62f1efwrowe
b5451913a64155af2eab4f12ecbaf16e15acafc3wrowe <p>If you have the <code>DEFLATE</code> filter activated, this
e13735ceb2025ea8ed0c530093e13fe57b62f1efwrowe environment variable will ignore the accept-encoding setting of
e13735ceb2025ea8ed0c530093e13fe57b62f1efwrowe your browser and will send compressed output unconditionally.</p>
8aced0b621ea45e8621c7073b0bfbe5ea91c2329wrowe
2b7078b0c4fd5b6054f6f2d4f626177844f5c6f7wrowe <h3><a name="force-no-vary" id="force-no-vary">force-no-vary</a></h3>
2b7078b0c4fd5b6054f6f2d4f626177844f5c6f7wrowe
2b7078b0c4fd5b6054f6f2d4f626177844f5c6f7wrowe
2b7078b0c4fd5b6054f6f2d4f626177844f5c6f7wrowe <p>This causes any <code>Vary</code> fields to be removed from
2b7078b0c4fd5b6054f6f2d4f626177844f5c6f7wrowe the response header before it is sent back to the client. Some
2b7078b0c4fd5b6054f6f2d4f626177844f5c6f7wrowe clients don't interpret this field correctly; setting this
af5dd1c93d2185f7e37f8783c593b64fd35ea8a6wrowe variable can work around this problem. Setting this variable
af5dd1c93d2185f7e37f8783c593b64fd35ea8a6wrowe also implies <strong>force-response-1.0</strong>.</p>
8dc154408549195c828b823e9dc7396f107f2512jorton
8dc154408549195c828b823e9dc7396f107f2512jorton
b79b480213d7452db127eec054e52eb2b4fa6153wrowe <h3><a name="force-response" id="force-response">force-response-1.0</a></h3>
417f504d4d11631c0d062be85347f82a26c88677aaron
417f504d4d11631c0d062be85347f82a26c88677aaron
7933d4a963def02417113b6798d87a36395053b0rse <p>This forces an HTTP/1.0 response to clients making an HTTP/1.0
7933d4a963def02417113b6798d87a36395053b0rse request. It was originally
9cb81d96f6b556cec1aa456191f43f7932aabaaedougm implemented as a result of a problem with AOL's proxies. Some
9cb81d96f6b556cec1aa456191f43f7932aabaaedougm HTTP/1.0 clients may not behave correctly when given an HTTP/1.1
9cb81d96f6b556cec1aa456191f43f7932aabaaedougm response, and this can be used to interoperate with them.</p>
9cb81d96f6b556cec1aa456191f43f7932aabaaedougm
9cb81d96f6b556cec1aa456191f43f7932aabaaedougm
9cb81d96f6b556cec1aa456191f43f7932aabaaedougm
9cb81d96f6b556cec1aa456191f43f7932aabaaedougm <h3><a name="gzip-only-text-html" id="gzip-only-text-html">gzip-only-text/html</a></h3>
9cb81d96f6b556cec1aa456191f43f7932aabaaedougm
9cb81d96f6b556cec1aa456191f43f7932aabaaedougm
9cb81d96f6b556cec1aa456191f43f7932aabaaedougm <p>When set to a value of "1", this variable disables the
9cb81d96f6b556cec1aa456191f43f7932aabaaedougm <code>DEFLATE</code> output filter provided by
9cb81d96f6b556cec1aa456191f43f7932aabaaedougm <code class="module"><a href="/mod/mod_deflate.html">mod_deflate</a></code> for content-types other than
9cb81d96f6b556cec1aa456191f43f7932aabaaedougm <code>text/html</code>. If you'd rather
9cb81d96f6b556cec1aa456191f43f7932aabaaedougm use statically compressed files, <code class="module"><a href="/mod/mod_negotiation.html">mod_negotiation</a></code>
9cb81d96f6b556cec1aa456191f43f7932aabaaedougm evaluates the variable as well (not only for gzip, but for all
9cb81d96f6b556cec1aa456191f43f7932aabaaedougm encodings that differ from "identity").</p>
9cb81d96f6b556cec1aa456191f43f7932aabaaedougm
cde1010d880fb6230f80c9d697842ea0b1cb79c7dougm
cde1010d880fb6230f80c9d697842ea0b1cb79c7dougm <h3><a name="no-gzip" id="no-gzip">no-gzip</a></h3>
9cb81d96f6b556cec1aa456191f43f7932aabaaedougm
9cb81d96f6b556cec1aa456191f43f7932aabaaedougm <p>When set, the <code>DEFLATE</code> filter of
cde1010d880fb6230f80c9d697842ea0b1cb79c7dougm <code class="module"><a href="/mod/mod_deflate.html">mod_deflate</a></code> will be turned off and
2261f694ce2fc09f9df6c65bd8e1f4230313696bjorton <code class="module"><a href="/mod/mod_negotiation.html">mod_negotiation</a></code> will refuse to deliver encoded
2261f694ce2fc09f9df6c65bd8e1f4230313696bjorton resources.</p>
2261f694ce2fc09f9df6c65bd8e1f4230313696bjorton
cde1010d880fb6230f80c9d697842ea0b1cb79c7dougm
cde1010d880fb6230f80c9d697842ea0b1cb79c7dougm
cde1010d880fb6230f80c9d697842ea0b1cb79c7dougm <h3><a name="no-cache" id="no-cache">no-cache</a></h3>
cde1010d880fb6230f80c9d697842ea0b1cb79c7dougm <p><em>Available in versions 2.2.12 and later</em></p>
9cb81d96f6b556cec1aa456191f43f7932aabaaedougm
621bd763d2e4d32f19013ac8b76b375b5a01851fdougm <p>When set, <code class="module"><a href="/mod/mod_cache.html">mod_cache</a></code> will not save an otherwise
621bd763d2e4d32f19013ac8b76b375b5a01851fdougm cacheable response. This environment variable does not influence
621bd763d2e4d32f19013ac8b76b375b5a01851fdougm whether a response already in the cache will be served for the current
621bd763d2e4d32f19013ac8b76b375b5a01851fdougm request.</p>
621bd763d2e4d32f19013ac8b76b375b5a01851fdougm
621bd763d2e4d32f19013ac8b76b375b5a01851fdougm
621bd763d2e4d32f19013ac8b76b375b5a01851fdougm
621bd763d2e4d32f19013ac8b76b375b5a01851fdougm <h3><a name="nokeepalive" id="nokeepalive">nokeepalive</a></h3>
621bd763d2e4d32f19013ac8b76b375b5a01851fdougm
621bd763d2e4d32f19013ac8b76b375b5a01851fdougm
621bd763d2e4d32f19013ac8b76b375b5a01851fdougm <p>This disables <code class="directive"><a href="/mod/core.html#keepalive">KeepAlive</a></code>
ccbf65bf19ac58a396133923aee4597e0870ec47bnicholes when set.</p>
621bd763d2e4d32f19013ac8b76b375b5a01851fdougm
621bd763d2e4d32f19013ac8b76b375b5a01851fdougm
621bd763d2e4d32f19013ac8b76b375b5a01851fdougm
621bd763d2e4d32f19013ac8b76b375b5a01851fdougm <h3><a name="prefer-language" id="prefer-language">prefer-language</a></h3>
621bd763d2e4d32f19013ac8b76b375b5a01851fdougm
621bd763d2e4d32f19013ac8b76b375b5a01851fdougm <p>This influences <code class="module"><a href="/mod/mod_negotiation.html">mod_negotiation</a></code>'s behaviour. If
9cb81d96f6b556cec1aa456191f43f7932aabaaedougm it contains a language tag (such as <code>en</code>, <code>ja</code>
9cb81d96f6b556cec1aa456191f43f7932aabaaedougm or <code>x-klingon</code>), <code class="module"><a href="/mod/mod_negotiation.html">mod_negotiation</a></code> tries
9cb81d96f6b556cec1aa456191f43f7932aabaaedougm to deliver a variant with that language. If there's no such variant,
9cb81d96f6b556cec1aa456191f43f7932aabaaedougm the normal <a href="content-negotiation.html">negotiation</a> process
4ede070ca63bd4c48045e35a7192582769770290jorton applies.</p>
7933d4a963def02417113b6798d87a36395053b0rse
a943533fd4d91d114af622731a405407990c4fb1rse
a943533fd4d91d114af622731a405407990c4fb1rse
9cb81d96f6b556cec1aa456191f43f7932aabaaedougm <h3><a name="redirect-carefully" id="redirect-carefully">redirect-carefully</a></h3>
469549ac22c6f7b9ecdd9df2565925563e4df84djwoolley
9cb81d96f6b556cec1aa456191f43f7932aabaaedougm
a943533fd4d91d114af622731a405407990c4fb1rse <p>This forces the server to be more careful when sending a redirect
a943533fd4d91d114af622731a405407990c4fb1rse to the client. This is typically used when a client has a known
e726f34f8da08c01ee8bc90904b26196b69c8587wrowe problem handling redirects. This was originally implemented as a
a943533fd4d91d114af622731a405407990c4fb1rse result of a problem with Microsoft's WebFolders software which has
e726f34f8da08c01ee8bc90904b26196b69c8587wrowe a problem handling redirects on directory resources via DAV
a943533fd4d91d114af622731a405407990c4fb1rse methods.</p>
9cb81d96f6b556cec1aa456191f43f7932aabaaedougm
9cb81d96f6b556cec1aa456191f43f7932aabaaedougm
9cb81d96f6b556cec1aa456191f43f7932aabaaedougm
9cb81d96f6b556cec1aa456191f43f7932aabaaedougm <h3><a name="suppress-error-charset" id="suppress-error-charset">suppress-error-charset</a></h3>
9cb81d96f6b556cec1aa456191f43f7932aabaaedougm
9cb81d96f6b556cec1aa456191f43f7932aabaaedougm
a943533fd4d91d114af622731a405407990c4fb1rse <p><em>Available in versions after 2.0.54</em></p>
a943533fd4d91d114af622731a405407990c4fb1rse
a943533fd4d91d114af622731a405407990c4fb1rse <p>When Apache issues a redirect in response to a client request,
a943533fd4d91d114af622731a405407990c4fb1rse the response includes some actual text to be displayed in case
a943533fd4d91d114af622731a405407990c4fb1rse the client can't (or doesn't) automatically follow the redirection.
9cb81d96f6b556cec1aa456191f43f7932aabaaedougm Apache ordinarily labels this text according to the character set
2261f694ce2fc09f9df6c65bd8e1f4230313696bjorton which it uses, which is ISO-8859-1.</p>
2261f694ce2fc09f9df6c65bd8e1f4230313696bjorton
2261f694ce2fc09f9df6c65bd8e1f4230313696bjorton <p> However, if the redirection is to a page that uses a different
e16695d440d82ec6f9a4b9af18ae38dbeaa19366jerenkrantz character set, some broken browser versions will try to use the
71c00f988beb28388702e14cb7fe06f08bd792bbdougm character set from the redirection text rather than the actual page.
a943533fd4d91d114af622731a405407990c4fb1rse This can result in Greek, for instance, being incorrectly rendered.</p>
71c00f988beb28388702e14cb7fe06f08bd792bbdougm
a943533fd4d91d114af622731a405407990c4fb1rse <p>Setting this environment variable causes Apache to omit the character
a943533fd4d91d114af622731a405407990c4fb1rse set for the redirection text, and these broken browsers will then correctly
6d7efb8c76b56eaebd6032096771c9e44b247f3fdougm use that of the destination page.</p>
f4c472b8dce3c2e559232dbb5b27ed2466922ea4jerenkrantz
f4c472b8dce3c2e559232dbb5b27ed2466922ea4jerenkrantz <div class="warning">
469549ac22c6f7b9ecdd9df2565925563e4df84djwoolley <h3>Security note</h3>
469549ac22c6f7b9ecdd9df2565925563e4df84djwoolley
d0ba3b97557d47323bd055fb4002ed7692f703b9jerenkrantz <p>Sending error pages without a specified character set may
71c00f988beb28388702e14cb7fe06f08bd792bbdougm allow a cross-site-scripting attack for existing browsers (MSIE)
2261f694ce2fc09f9df6c65bd8e1f4230313696bjorton which do not follow the HTTP/1.1 specification and attempt to
2261f694ce2fc09f9df6c65bd8e1f4230313696bjorton "guess" the character set from the content. Such browsers can
e16695d440d82ec6f9a4b9af18ae38dbeaa19366jerenkrantz be easily fooled into using the UTF-7 character set, and UTF-7
71c00f988beb28388702e14cb7fe06f08bd792bbdougm content from input data (such as the request-URI) will not be
a943533fd4d91d114af622731a405407990c4fb1rse escaped by the usual escaping mechanisms designed to prevent
71c00f988beb28388702e14cb7fe06f08bd792bbdougm cross-site-scripting attacks.</p>
a943533fd4d91d114af622731a405407990c4fb1rse </div>
a943533fd4d91d114af622731a405407990c4fb1rse
71c00f988beb28388702e14cb7fe06f08bd792bbdougm
a943533fd4d91d114af622731a405407990c4fb1rse
d28d7091912b3d911bdbe18df2d37d315681054bdougm <h3><a name="proxy" id="proxy">force-proxy-request-1.0, proxy-nokeepalive, proxy-sendchunked,
a943533fd4d91d114af622731a405407990c4fb1rse proxy-sendcl, proxy-chain-auth, proxy-interim-response, proxy-initial-not-pooled</a></h3>
931b4fd1cc9dd3da096c45f4bf7ddcc14e0985c1dougm
a943533fd4d91d114af622731a405407990c4fb1rse <p>These directives alter the protocol behavior of
a943533fd4d91d114af622731a405407990c4fb1rse <code class="module"><a href="/mod/mod_proxy.html">mod_proxy</a></code>. See the <code class="module"><a href="/mod/mod_proxy.html">mod_proxy</a></code> and <code class="module"><a href="/mod/mod_proxy_http.html">mod_proxy_http</a></code>
a943533fd4d91d114af622731a405407990c4fb1rse documentation for more details.</p>
a943533fd4d91d114af622731a405407990c4fb1rse
a943533fd4d91d114af622731a405407990c4fb1rse
a943533fd4d91d114af622731a405407990c4fb1rse </div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
c947acd3d1a604a0acad6a53ef685312d4410fc5dougm<div class="section">
a943533fd4d91d114af622731a405407990c4fb1rse<h2><a name="examples" id="examples">Examples</a></h2>
a943533fd4d91d114af622731a405407990c4fb1rse
4ede070ca63bd4c48045e35a7192582769770290jorton
a943533fd4d91d114af622731a405407990c4fb1rse <h3><a name="fixheader" id="fixheader">Passing broken headers to CGI scripts</a></h3>
a943533fd4d91d114af622731a405407990c4fb1rse
7933d4a963def02417113b6798d87a36395053b0rse
7933d4a963def02417113b6798d87a36395053b0rse <p>Starting with version 2.4, Apache is more strict about how HTTP
7b6ba9c468f26bdb3492d5e8cb79628a3b04e8c8wrowe headers are converted to environment variables in <code class="module"><a href="/mod/mod_cgi&#10; .html">mod_cgi
7933d4a963def02417113b6798d87a36395053b0rse </a></code> and other modules: Previously any invalid characters
a943533fd4d91d114af622731a405407990c4fb1rse in header names were simply translated to underscores. This allowed
a943533fd4d91d114af622731a405407990c4fb1rse for some potential cross-site-scripting attacks via header injection
2f32a3d146dc55d81b31660386e17c3b83ad61b8bnicholes (see <a href="http://events.ccc.de/congress/2007/Fahrplan/events/2212.en.html">
a943533fd4d91d114af622731a405407990c4fb1rse Unusual Web Bugs</a>, slide 19/20).</p>
71c00f988beb28388702e14cb7fe06f08bd792bbdougm
a943533fd4d91d114af622731a405407990c4fb1rse <p>If you have to support a client which sends broken headers and
a943533fd4d91d114af622731a405407990c4fb1rse which can't be fixed, a simple workaround involving <code class="module"><a href="/mod/mod_setenvif&#10; .html">mod_setenvif
7933d4a963def02417113b6798d87a36395053b0rse </a></code> and <code class="module"><a href="/mod/mod_header.html">mod_header</a></code> allows you to still accept
7933d4a963def02417113b6798d87a36395053b0rse these headers:</p>
71c00f988beb28388702e14cb7fe06f08bd792bbdougm
7933d4a963def02417113b6798d87a36395053b0rse<div class="example"><p><code>
a943533fd4d91d114af622731a405407990c4fb1rse# <br />
a943533fd4d91d114af622731a405407990c4fb1rse# The following works around a client sending a broken Accept_Encoding<br />
2f32a3d146dc55d81b31660386e17c3b83ad61b8bnicholes# header.<br />
a943533fd4d91d114af622731a405407990c4fb1rse#<br />
71c00f988beb28388702e14cb7fe06f08bd792bbdougmSetEnvIfNoCase ^Accept.Encoding$ ^(.*)$ fix_accept_encoding=$1<br />
71c00f988beb28388702e14cb7fe06f08bd792bbdougmRequestHeader set Accept-Encoding %{fix_accept_encoding}e env=fix_accept_encoding
a943533fd4d91d114af622731a405407990c4fb1rse</code></p></div>
7933d4a963def02417113b6798d87a36395053b0rse
7933d4a963def02417113b6798d87a36395053b0rse
e726f34f8da08c01ee8bc90904b26196b69c8587wrowe
e726f34f8da08c01ee8bc90904b26196b69c8587wrowe <h3><a name="misbehaving" id="misbehaving">Changing protocol behavior with misbehaving clients</a></h3>
e726f34f8da08c01ee8bc90904b26196b69c8587wrowe
e726f34f8da08c01ee8bc90904b26196b69c8587wrowe
e726f34f8da08c01ee8bc90904b26196b69c8587wrowe <p>Earlier versions recommended that the following lines be included in
e726f34f8da08c01ee8bc90904b26196b69c8587wrowe httpd.conf to deal with known client problems. Since the affected clients
e726f34f8da08c01ee8bc90904b26196b69c8587wrowe are no longer seen in the wild, this configuration is likely no-longer
e726f34f8da08c01ee8bc90904b26196b69c8587wrowe necessary.</p>
ccbf65bf19ac58a396133923aee4597e0870ec47bnicholes<div class="example"><p><code>
e726f34f8da08c01ee8bc90904b26196b69c8587wrowe#<br />
e726f34f8da08c01ee8bc90904b26196b69c8587wrowe# The following directives modify normal HTTP response behavior.<br />
e726f34f8da08c01ee8bc90904b26196b69c8587wrowe# The first directive disables keepalive for Netscape 2.x and browsers that<br />
e726f34f8da08c01ee8bc90904b26196b69c8587wrowe# spoof it. There are known problems with these browser implementations.<br />
e726f34f8da08c01ee8bc90904b26196b69c8587wrowe# The second directive is for Microsoft Internet Explorer 4.0b2<br />
e726f34f8da08c01ee8bc90904b26196b69c8587wrowe# which has a broken HTTP/1.1 implementation and does not properly<br />
e726f34f8da08c01ee8bc90904b26196b69c8587wrowe# support keepalive when it is used on 301 or 302 (redirect) responses.<br />
e726f34f8da08c01ee8bc90904b26196b69c8587wrowe#<br />
e726f34f8da08c01ee8bc90904b26196b69c8587wroweBrowserMatch "Mozilla/2" nokeepalive<br />
e726f34f8da08c01ee8bc90904b26196b69c8587wroweBrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0<br />
e726f34f8da08c01ee8bc90904b26196b69c8587wrowe<br />
e726f34f8da08c01ee8bc90904b26196b69c8587wrowe#<br />
e726f34f8da08c01ee8bc90904b26196b69c8587wrowe# The following directive disables HTTP/1.1 responses to browsers which<br />
e726f34f8da08c01ee8bc90904b26196b69c8587wrowe# are in violation of the HTTP/1.0 spec by not being able to understand a<br />
e726f34f8da08c01ee8bc90904b26196b69c8587wrowe# basic 1.1 response.<br />
e726f34f8da08c01ee8bc90904b26196b69c8587wrowe#<br />
e726f34f8da08c01ee8bc90904b26196b69c8587wroweBrowserMatch "RealPlayer 4\.0" force-response-1.0<br />
e726f34f8da08c01ee8bc90904b26196b69c8587wroweBrowserMatch "Java/1\.0" force-response-1.0<br />
e726f34f8da08c01ee8bc90904b26196b69c8587wroweBrowserMatch "JDK/1\.0" force-response-1.0
e726f34f8da08c01ee8bc90904b26196b69c8587wrowe</code></p></div>
e726f34f8da08c01ee8bc90904b26196b69c8587wrowe
2261f694ce2fc09f9df6c65bd8e1f4230313696bjorton
2261f694ce2fc09f9df6c65bd8e1f4230313696bjorton <h3><a name="no-img-log" id="no-img-log">Do not log requests for images in the access log</a></h3>
2261f694ce2fc09f9df6c65bd8e1f4230313696bjorton
e726f34f8da08c01ee8bc90904b26196b69c8587wrowe
4ede070ca63bd4c48045e35a7192582769770290jorton <p>This example keeps requests for images from appearing in the
e726f34f8da08c01ee8bc90904b26196b69c8587wrowe access log. It can be easily modified to prevent logging of
e726f34f8da08c01ee8bc90904b26196b69c8587wrowe particular directories, or to prevent logging of requests
e726f34f8da08c01ee8bc90904b26196b69c8587wrowe coming from particular hosts.</p>
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse
7933d4a963def02417113b6798d87a36395053b0rse <div class="example"><p><code>
cc003103e52ff9d5fe9bed567ef9438613ab4fbfrse SetEnvIf Request_URI \.gif image-request<br />
a943533fd4d91d114af622731a405407990c4fb1rse SetEnvIf Request_URI \.jpg image-request<br />
7933d4a963def02417113b6798d87a36395053b0rse SetEnvIf Request_URI \.png image-request<br />
7933d4a963def02417113b6798d87a36395053b0rse CustomLog logs/access_log common env=!image-request
825479074daa2c65852666c4b26d771dff957507jorton </code></p></div>
e8f95a682820a599fe41b22977010636be5c2717jim
825479074daa2c65852666c4b26d771dff957507jorton
825479074daa2c65852666c4b26d771dff957507jorton <h3><a name="image-theft" id="image-theft">Prevent "Image Theft"</a></h3>
a943533fd4d91d114af622731a405407990c4fb1rse
dfaea9dfb7e6fd2c97b9d35a75d7bcab94af8ff8dougm
a943533fd4d91d114af622731a405407990c4fb1rse <p>This example shows how to keep people not on your server
d2ffb32434f79782ff7a364ffa31064698c5c645jorton from using images on your server as inline-images on their
a943533fd4d91d114af622731a405407990c4fb1rse pages. This is not a recommended configuration, but it can work
7b6ba9c468f26bdb3492d5e8cb79628a3b04e8c8wrowe in limited circumstances. We assume that all your images are in
a943533fd4d91d114af622731a405407990c4fb1rse a directory called <code>/web/images</code>.</p>
fa599e0e097d4d933c4dc378ffbfc3c045dd589ewrowe
a943533fd4d91d114af622731a405407990c4fb1rse <div class="example"><p><code>
0fce4eaa9fdf964f33fab19d0adac422a5305261dougm SetEnvIf Referer "^http://www\.example\.com/" local_referal<br />
a943533fd4d91d114af622731a405407990c4fb1rse # Allow browsers that do not send Referer info<br />
a943533fd4d91d114af622731a405407990c4fb1rse SetEnvIf Referer "^$" local_referal<br />
0fce4eaa9fdf964f33fab19d0adac422a5305261dougm &lt;Directory /web/images&gt;<br />
825479074daa2c65852666c4b26d771dff957507jorton <span class="indent">
dfaea9dfb7e6fd2c97b9d35a75d7bcab94af8ff8dougm Order Deny,Allow<br />
17f61d2695369a9b62bc0e5f38e9c4d23eebc664jorton Deny from all<br />
9cb81d96f6b556cec1aa456191f43f7932aabaaedougm Allow from env=local_referal
9cb81d96f6b556cec1aa456191f43f7932aabaaedougm </span>
621bd763d2e4d32f19013ac8b76b375b5a01851fdougm &lt;/Directory&gt;
7933d4a963def02417113b6798d87a36395053b0rse </code></p></div>
7933d4a963def02417113b6798d87a36395053b0rse
6ace32dacb8313226eb9019275d0e4fa45a15148rse <p>For more information about this technique, see the
6ace32dacb8313226eb9019275d0e4fa45a15148rse "<a href="http://www.serverwatch.com/tutorials/article.php/1132731">Keeping Your Images from Adorning Other Sites</a>"
7933d4a963def02417113b6798d87a36395053b0rse tutorial on ServerWatch.</p>
7933d4a963def02417113b6798d87a36395053b0rse
7933d4a963def02417113b6798d87a36395053b0rse </div></div>
7933d4a963def02417113b6798d87a36395053b0rse<div class="bottomlang">
7933d4a963def02417113b6798d87a36395053b0rse<p><span>Available Languages: </span><a href="/en/env.html" title="English">&nbsp;en&nbsp;</a> |
7933d4a963def02417113b6798d87a36395053b0rse<a href="/fr/env.html" hreflang="fr" rel="alternate" title="Fran�ais">&nbsp;fr&nbsp;</a> |
6ace32dacb8313226eb9019275d0e4fa45a15148rse<a href="/ja/env.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
<a href="/ko/env.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a> |
<a href="/tr/env.html" hreflang="tr" rel="alternate" title="T�rk�e">&nbsp;tr&nbsp;</a></p>
</div><div id="footer">
<p class="apache">Copyright 2011 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="/faq/">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p></div>
</body></html>