📄 mod_setenvif.html.en
字号:
<?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!-- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX This file is generated from xml source: DO NOT EDIT XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX --><title>mod_setenvif - Apache HTTP Server</title><link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /><link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /><link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link href="../images/favicon.ico" rel="shortcut icon" /></head><body><div id="page-header"><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><p class="apache">Apache HTTP Server Version 2.0</p><img alt="" src="../images/feather.gif" /></div><div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div><div id="path"><a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.0</a> > <a href="./">Modules</a></div><div id="page-content"><div id="preamble"><h1>Apache Module mod_setenvif</h1><div class="toplang"><p><span>Available Languages: </span><a href="../en/mod/mod_setenvif.html" title="English"> en </a> |<a href="../ja/mod/mod_setenvif.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> |<a href="../ko/mod/mod_setenvif.html" hreflang="ko" rel="alternate" title="Korean"> ko </a></p></div><table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Allows the setting of environment variables basedon characteristics of the request</td></tr><tr><th><a href="module-dict.html#Status">Status:</a></th><td>Base</td></tr><tr><th><a href="module-dict.html#ModuleIdentifier">Module營dentifier:</a></th><td>setenvif_module</td></tr><tr><th><a href="module-dict.html#SourceFile">Source燜ile:</a></th><td>mod_setenvif.c</td></tr></table><h3>Summary</h3> <p>The <code class="module"><a href="../mod/mod_setenvif.html">mod_setenvif</a></code> module allows you to set environment variables according to whether different aspects of the request match regular expressions you specify. These environment variables can be used by other parts of the server to make decisions about actions to be taken.</p> <p>The directives are considered in the order they appear in the configuration files. So more complex sequences can be used, such as this example, which sets <code>netscape</code> if the browser is mozilla but not MSIE.</p><div class="example"><p><code> BrowserMatch ^Mozilla netscape<br /> BrowserMatch MSIE !netscape<br /></code></p></div></div><div id="quickview"><h3 class="directives">Directives</h3><ul id="toc"><li><img alt="" src="../images/down.gif" /> <a href="#browsermatch">BrowserMatch</a></li><li><img alt="" src="../images/down.gif" /> <a href="#browsermatchnocase">BrowserMatchNoCase</a></li><li><img alt="" src="../images/down.gif" /> <a href="#setenvif">SetEnvIf</a></li><li><img alt="" src="../images/down.gif" /> <a href="#setenvifnocase">SetEnvIfNoCase</a></li></ul><h3>See also</h3><ul class="seealso"><li><a href="../env.html">Environment Variables in Apache</a></li></ul></div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="directive-section"><h2><a name="BrowserMatch" id="BrowserMatch">BrowserMatch</a> <a name="browsermatch" id="browsermatch">Directive</a></h2><table class="directive"><tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets environment variables conditional on HTTP User-Agent</td></tr><tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>BrowserMatch <em>regex [!]env-variable</em>[=<em>value</em>][[!]<em>env-variable</em>[=<em>value</em>]] ...</code></td></tr><tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr><tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr><tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr><tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_setenvif</td></tr></table> <p>The <code class="directive">BrowserMatch</code> is a special cases of the <code class="directive"><a href="#setenvif">SetEnvIf</a></code> directive that sets environment variables conditional on the <code>User-Agent</code> HTTP request header. The following two lines have the same effect:</p><div class="example"><p><code> BrowserMatchNoCase Robot is_a_robot<br /> SetEnvIfNoCase User-Agent Robot is_a_robot<br /> </code></p></div> <p>Some additional examples:</p><div class="example"><p><code> BrowserMatch ^Mozilla forms jpeg=yes browser=netscape<br /> BrowserMatch "^Mozilla/[2-3]" tables agif frames javascript<br /> BrowserMatch MSIE !javascript<br /></code></p></div></div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="directive-section"><h2><a name="BrowserMatchNoCase" id="BrowserMatchNoCase">BrowserMatchNoCase</a> <a name="browsermatchnocase" id="browsermatchnocase">Directive</a></h2><table class="directive"><tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets environment variables conditional on User-Agent withoutrespect to case</td></tr><tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>BrowserMatchNoCase <em>regex [!]env-variable</em>[=<em>value</em>] [[!]<em>env-variable</em>[=<em>value</em>]] ...</code></td></tr><tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr><tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr><tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr><tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_setenvif</td></tr><tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>Apache 1.2 and above (in Apache 1.2 this directive was found in the now-obsolete mod_browser module)</td></tr></table> <p>The <code class="directive">BrowserMatchNoCase</code> directive is semantically identical to the <code class="directive"><a href="#browsermatch">BrowserMatch</a></code> directive. However, it provides for case-insensitive matching. For example:</p><div class="example"><p><code> BrowserMatchNoCase mac platform=macintosh<br /> BrowserMatchNoCase win platform=windows<br /></code></p></div> <p>The <code class="directive">BrowserMatch</code> and <code class="directive">BrowserMatchNoCase</code> directives are special cases of the <code class="directive"><a href="#setenvif">SetEnvIf</a></code> and <code class="directive"><a href="#setenvifnocase">SetEnvIfNoCase</a></code> directives. The following two lines have the same effect:</p><div class="example"><p><code> BrowserMatchNoCase Robot is_a_robot<br /> SetEnvIfNoCase User-Agent Robot is_a_robot<br /></code></p></div></div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="directive-section"><h2><a name="SetEnvIf" id="SetEnvIf">SetEnvIf</a> <a name="setenvif" id="setenvif">Directive</a></h2><table class="directive"><tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets environment variables based on attributes of the request</td></tr><tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>SetEnvIf <em>attribute regex [!]env-variable</em>[=<em>value</em>] [[!]<em>env-variable</em>[=<em>value</em>]] ...</code></td></tr><tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr><tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr><tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr><tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_setenvif</td></tr></table> <p>The <code class="directive">SetEnvIf</code> directive defines environment variables based on attributes of the request. The
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -