mod_setenvif.html revision d030d579df50673f566f5dbcd1904fd59cd310e0
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz<HTML>
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz <HEAD>
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz <TITLE>Apache module mod_setenvif</TITLE>
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz </HEAD>
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd <BODY
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd BGCOLOR="#FFFFFF"
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd TEXT="#000000"
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd LINK="#0000FF"
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd VLINK="#000080"
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd ALINK="#FF0000"
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd >
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd<!--#include virtual="header.html" -->
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd <H1 ALIGN="CENTER">Module mod_setenvif</H1>
52fff662005b1866a3ff09bb6c902800c5cc6dedjerenkrantz <P>
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd This module is contained in the <SAMP>mod_setenvif.c</SAMP> file, and
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd <STRONG>is</STRONG> compiled in by default. It provides for
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd the ability to set environment variables based upon attributes of the
4b5981e276e93df97c34e4da05ca5cf8bbd937dand request.
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd </P>
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd <H2>Summary</H2>
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd <P>
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd The <SAMP>mod_setenvif</SAMP> module allows you to set environment
a78048ccbdb6256da15e6b0e7e95355e480c2301nd variables according to whether different aspects of the request match
a78048ccbdb6256da15e6b0e7e95355e480c2301nd regular expressions you specify. These envariables can be used by
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd other parts of the server to make decisions about actions to be taken.
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd </P>
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd <P>The directives are considered in the order they appear in the
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd configuration files. So more complex sequences can be used, such
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd as this example, which sets <CODE>netscape</CODE> if the browser
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd is mozilla but not MSIE.
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <BLOCKQUOTE><PRE>
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd BrowserMatch ^Mozilla netscape
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd BrowserMatch MSIE !netscape
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin </PRE></BLOCKQUOTE>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin </P>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <H2>Directives</H2>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <UL>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <LI><A HREF="#BrowserMatch">BrowserMatch</A>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin </LI>
cb3a1082aec4b3b4f4ed238c93c3cc54933a7f0end <LI><A HREF="#BrowserMatchNoCase">BrowserMatchNoCase</A>
cb3a1082aec4b3b4f4ed238c93c3cc54933a7f0end </LI>
cb3a1082aec4b3b4f4ed238c93c3cc54933a7f0end <LI><A HREF="#SetEnvIf">SetEnvIf</A>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin </LI>
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz <LI><A HREF="#SetEnvIfNoCase">SetEnvIfNoCase</A>
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz </LI>
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz </UL>
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz <HR> <!-- the HR is part of the directive description -->
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz <H2><A NAME="BrowserMatch">The <SAMP>BrowserMatch</SAMP> Directive</A></H2>
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz <P>
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd <A
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd HREF="directive-dict.html#Syntax"
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin REL="Help"
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin ><STRONG>Syntax:</STRONG></A> BrowserMatch <EM>regex envar[=value] [...]</EM>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <BR>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <A
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin HREF="directive-dict.html#Default"
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin REL="Help"
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd ><STRONG>Default:</STRONG></A> <EM>none</EM>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <BR>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <A
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin HREF="directive-dict.html#Context"
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin REL="Help"
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd ><STRONG>Context:</STRONG></A> server config
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd <BR>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <A
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin HREF="directive-dict.html#Override"
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin REL="Help"
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin ><STRONG>Override:</STRONG></A> <EM>none</EM>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <BR>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <A
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin HREF="directive-dict.html#Status"
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin REL="Help"
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin ><STRONG>Status:</STRONG></A> Base
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <BR>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <A
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin HREF="directive-dict.html#Module"
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz REL="Help"
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz ><STRONG>Module:</STRONG></A> mod_setenvif
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz <BR>
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz <A
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz HREF="directive-dict.html#Compatibility"
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin REL="Help"
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz ><STRONG>Compatibility:</STRONG></A> Apache 1.2 and above
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin </P>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <P>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin The BrowserMatch directive defines environment variables based on the
aa0b2780958e9b1467c9d0153a05738e399811a5nd <SAMP>User-Agent</SAMP> HTTP request header field. The first argument
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz should be a POSIX.2 extended regular expression (similar to an
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz <SAMP>egrep</SAMP>-style regex). The rest of the arguments give the
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz names of variables to set, and optionally values to which they should
aa0b2780958e9b1467c9d0153a05738e399811a5nd be set. These take the form of
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz </P>
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz <OL>
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz <LI><SAMP><EM>varname</EM></SAMP>, or
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin </LI>
aa0b2780958e9b1467c9d0153a05738e399811a5nd <LI><SAMP>!<EM>varname</EM></SAMP>, or
f47ff652f30fc6cdfc8b36114e7f9710db9aded8nd </LI>
aa0b2780958e9b1467c9d0153a05738e399811a5nd <LI><SAMP><EM>varname</EM>=<EM>value</EM></SAMP>
aa0b2780958e9b1467c9d0153a05738e399811a5nd </LI>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin </OL>
aa0b2780958e9b1467c9d0153a05738e399811a5nd <P>
aa0b2780958e9b1467c9d0153a05738e399811a5nd In the first form, the value will be set to &quot;1&quot;. The second
aa0b2780958e9b1467c9d0153a05738e399811a5nd will remove the given variable if already defined, and the third will
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin set the variable to the value given by <SAMP><EM>value</EM></SAMP>. If a
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz <SAMP>User-Agent</SAMP> string matches more than one entry, they will
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz be merged. Entries are processed in the order in which they appear,
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz and later entries can override earlier ones.
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd </P>
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd <P>
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz For example:
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin </P>
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz <PRE>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin BrowserMatch ^Mozilla forms jpeg=yes browser=netscape
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin BrowserMatch "^Mozilla/[2-3]" tables agif frames javascript
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin BrowserMatch MSIE !javascript
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin </PRE>
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz <P>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin Note that the regular expression string is
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <STRONG>case-sensitive</STRONG>. For cane-INsensitive matching, see
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin the
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <A
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin HREF="#BrowserMatchNoCase"
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin ><SAMP>BrowserMatchNoCase</SAMP></A>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin directive.
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin </P>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <P>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin The <SAMP>BrowserMatch</SAMP> and <SAMP>BrowserMatchNoCase</SAMP>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin directives are special cases of the
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <A
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin HREF="#SetEnvIf"
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin ><SAMP>SetEnvIf</SAMP></A>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin and
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <A
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin HREF="#SetEnvIfNoCase"
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin ><SAMP>SetEnvIfNoCase</SAMP></A>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin directives. The following two lines have the same effect:
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin </P>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <PRE>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin BrowserMatchNoCase Robot is_a_robot
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin SetEnvIfNoCase User-Agent Robot is_a_robot
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin </PRE>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <HR> <!-- the HR is part of the directive description -->
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <H2>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <A NAME="BrowserMatchNoCase">
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin The <SAMP>BrowserMatchNoCase</SAMP> Directive
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin </A>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin </H2>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <P>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <A
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin HREF="directive-dict.html#Syntax"
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin REL="Help"
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin ><STRONG>Syntax:</STRONG></A> BrowserMatchNoCase <EM>regex envar[=value]
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin [...]</EM>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <BR>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <A
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin HREF="directive-dict.html#Default"
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin REL="Help"
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin ><STRONG>Default:</STRONG></A> <EM>none</EM>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <BR>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <A
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz HREF="directive-dict.html#Context"
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz REL="Help"
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz ><STRONG>Context:</STRONG></A> server config
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz <BR>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <A
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz HREF="directive-dict.html#Override"
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin REL="Help"
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin ><STRONG>Override:</STRONG></A> <EM>none</EM>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <BR>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <A
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz HREF="directive-dict.html#Status"
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin REL="Help"
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin ><STRONG>Status:</STRONG></A> Base
aa0b2780958e9b1467c9d0153a05738e399811a5nd <BR>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <A
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin HREF="directive-dict.html#Module"
aa0b2780958e9b1467c9d0153a05738e399811a5nd REL="Help"
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin ><STRONG>Module:</STRONG></A> mod_setenvif
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <BR>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <A
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin HREF="directive-dict.html#Compatibility"
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin REL="Help"
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin ><STRONG>Compatibility:</STRONG></A> Apache 1.2 and above
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin </P>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <P>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin The <SAMP>BrowserMatchNoCase</SAMP> directive is semantically identical to
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin the
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <A
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin HREF="#BrowserMatch"
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz ><SAMP>BrowserMatch</SAMP></A>
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz directive. However, it provides for case-insensitive matching. For
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz example:
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin </P>
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz <PRE>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin BrowserMatchNoCase mac platform=macintosh
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin BrowserMatchNoCase win platform=windows
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin </PRE>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <P>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin The <SAMP>BrowserMatch</SAMP> and <SAMP>BrowserMatchNoCase</SAMP>
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz directives are special cases of the
aa0b2780958e9b1467c9d0153a05738e399811a5nd <A
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin HREF="#SetEnvIf"
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin ><SAMP>SetEnvIf</SAMP></A>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin and
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <A
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin HREF="#SetEnvIfNoCase"
aa0b2780958e9b1467c9d0153a05738e399811a5nd ><SAMP>SetEnvIfNoCase</SAMP></A>
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz directives. The following two lines have the same effect:
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz </P>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <PRE>
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd BrowserMatchNoCase Robot is_a_robot
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd SetEnvIfNoCase User-Agent Robot is_a_robot
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd </PRE>
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd <HR> <!-- the HR is part of the directive description -->
a78048ccbdb6256da15e6b0e7e95355e480c2301nd <H2>
a78048ccbdb6256da15e6b0e7e95355e480c2301nd <A NAME="SetEnvIf">
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd The <SAMP>SetEnvIf</SAMP> Directive
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin </A>
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd </H2>
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd <P>
<A
HREF="directive-dict.html#Syntax"
REL="Help"
><STRONG>Syntax:</STRONG></A> SetEnvIf <EM> attribute regex envar[=value]
[...]</EM>
<BR>
<A
HREF="directive-dict.html#Default"
REL="Help"
><STRONG>Default:</STRONG></A> <EM>none</EM>
<BR>
<A
HREF="directive-dict.html#Context"
REL="Help"
><STRONG>Context:</STRONG></A> server config
<BR>
<A
HREF="directive-dict.html#Override"
REL="Help"
><STRONG>Override:</STRONG></A> <EM>none</EM>
<BR>
<A
HREF="directive-dict.html#Status"
REL="Help"
><STRONG>Status:</STRONG></A> Base
<BR>
<A
HREF="directive-dict.html#Module"
REL="Help"
><STRONG>Module:</STRONG></A> mod_setenvif
<BR>
<A
HREF="directive-dict.html#Compatibility"
REL="Help"
><STRONG>Compatibility:</STRONG></A> Apache 1.3 and above
</P>
<P>
The <SAMP>SetEnvIf</SAMP> directive defines environment variables
based on attributes of the request. These attributes can be the
values of various HTTP request header fields (see
<A
HREF="http://ds.internic.net/rfc/rfc2068.txt"
>RFC2068</A>
for more information about these), or of other aspects of the request,
including the following:
</P>
<UL>
<LI><SAMP>Remote_Host</SAMP> - the hostname (if available) of the
client making the request
</LI>
<LI><SAMP>Remote_Addr</SAMP> - the IP address of the client making
the request
</LI>
<LI><SAMP>Remote_User</SAMP> - the authenticated username (if
available)
</LI>
<LI><SAMP>Request_Method</SAMP> - the name of the method being used
(<SAMP>GET</SAMP>, <SAMP>POST</SAMP>, <EM>et cetera</EM>)
</LI>
<LI><SAMP>Request_URI</SAMP> - the portion of the URL following the
scheme and host portion
</LI>
</UL>
<P>
Some of the more commonly used request header field names include
<SAMP>Host</SAMP>, <SAMP>User-Agent</SAMP>, and <SAMP>Referer</SAMP>.
</P>
<P>
Example:
</P>
<PRE>
SetEnvIf Request_URI "\.(gif)|(jpg)|(xbm)$" object_is_image
SetEnvIf Referer www\.mydomain\.com intra_site_referral
</PRE>
<P>
The first will set the envariable <SAMP>object_is_image</SAMP> if the
request was for an image file, and the second sets
<SAMP>intra_site_referral</SAMP> if the referring page was somewhere
on the <SAMP>www.mydomain.com</SAMP> Web site.
</P>
<HR> <!-- the HR is part of the directive description -->
<H2>
<A NAME="SetEnvIfNoCase">
The <SAMP>SetEnvIfNoCase</SAMP> Directive
</A>
</H2>
<P>
<A
HREF="directive-dict.html#Syntax"
REL="Help"
><STRONG>Syntax:</STRONG></A> SetEnvIfNoCase
<EM> attribute regex envar[=value] [...]</EM>
<BR>
<A
HREF="directive-dict.html#Default"
REL="Help"
><STRONG>Default:</STRONG></A> <EM>none</EM>
<BR>
<A
HREF="directive-dict.html#Context"
REL="Help"
><STRONG>Context:</STRONG></A> server config
<BR>
<A
HREF="directive-dict.html#Override"
REL="Help"
><STRONG>Override:</STRONG></A> <EM>none</EM>
<BR>
<A
HREF="directive-dict.html#Status"
REL="Help"
><STRONG>Status:</STRONG></A> Base
<BR>
<A
HREF="directive-dict.html#Module"
REL="Help"
><STRONG>Module:</STRONG></A> mod_setenvif
<BR>
<A
HREF="directive-dict.html#Compatibility"
REL="Help"
><STRONG>Compatibility:</STRONG></A> Apache 1.3 and above
</P>
<P>
The <SAMP>SetEnvIfNoCase</SAMP> is semantically identical to the
<A
HREF="#SetEnvIf"
><SAMP>SetEnvIf</SAMP></A>
directive, and differs only in that the regular expression matching is
performed in a case-insensitive manner. For example:
</P>
<PRE>
SetEnvIfNoCase Host Apache\.Org site=apache
</PRE>
<P>
This will cause the <SAMP>site</SAMP> envariable to be set to
&quot;<SAMP>apache</SAMP>&quot; if the HTTP request header field
<SAMP>Host:</SAMP> was included and contained <SAMP>Apache.Org</SAMP>,
<SAMP>apache.org</SAMP>, or any other combination.
</P>
<!--#include virtual="footer.html" -->
</BODY>
</HTML>