mod_setenvif.html revision d030d579df50673f566f5dbcd1904fd59cd310e0
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd BGCOLOR="#FFFFFF"
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd TEXT="#000000"
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd LINK="#0000FF"
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd VLINK="#000080"
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd ALINK="#FF0000"
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd<!--#include virtual="header.html" -->
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
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>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.
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd BrowserMatch ^Mozilla netscape
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd BrowserMatch MSIE !netscape
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz <LI><A HREF="#SetEnvIfNoCase">SetEnvIfNoCase</A>
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz <HR> <!-- the HR is part of the directive description -->
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz <H2><A NAME="BrowserMatch">The <SAMP>BrowserMatch</SAMP> Directive</A></H2>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin ><STRONG>Syntax:</STRONG></A> BrowserMatch <EM>regex envar[=value] [...]</EM>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin HREF="directive-dict.html#Override"
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz HREF="directive-dict.html#Compatibility"
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz ><STRONG>Compatibility:</STRONG></A> Apache 1.2 and above
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
aa0b2780958e9b1467c9d0153a05738e399811a5nd In the first form, the value will be set to "1". 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.
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz For example:
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin BrowserMatch ^Mozilla forms jpeg=yes browser=netscape
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin BrowserMatch "^Mozilla/[2-3]" tables agif frames javascript
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin BrowserMatch MSIE !javascript
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin Note that the regular expression string is
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <STRONG>case-sensitive</STRONG>. For cane-INsensitive matching, see
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin HREF="#BrowserMatchNoCase"
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin The <SAMP>BrowserMatch</SAMP> and <SAMP>BrowserMatchNoCase</SAMP>
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin directives are special cases of the
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin HREF="#SetEnvIf"
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin HREF="#SetEnvIfNoCase"
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin directives. The following two lines have the same effect:
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin BrowserMatchNoCase Robot is_a_robot
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin SetEnvIfNoCase User-Agent Robot is_a_robot
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin <HR> <!-- the HR is part of the directive description -->
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin ><STRONG>Syntax:</STRONG></A> BrowserMatchNoCase <EM>regex envar[=value]
aa0b2780958e9b1467c9d0153a05738e399811a5nd REL="Help"
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin HREF="directive-dict.html#Compatibility"
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin ><STRONG>Compatibility:</STRONG></A> Apache 1.2 and above
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin The <SAMP>BrowserMatchNoCase</SAMP> directive is semantically identical to
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin HREF="#BrowserMatch"
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz directive. However, it provides for case-insensitive matching. For
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin BrowserMatchNoCase mac platform=macintosh
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin BrowserMatchNoCase win platform=windows
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin The <SAMP>BrowserMatch</SAMP> and <SAMP>BrowserMatchNoCase</SAMP>
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz directives are special cases of the
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin HREF="#SetEnvIf"
8951c7d73bfa2ae5a2c8fe5bd27f3e677be02564noirin HREF="#SetEnvIfNoCase"
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz directives. The following two lines have the same effect:
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd BrowserMatchNoCase Robot is_a_robot
bdd978e5ecd8daa2542d4d4e1988c78a622cd7f4nd SetEnvIfNoCase User-Agent Robot is_a_robot
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd <HR> <!-- the HR is part of the directive description -->
HREF="directive-dict.html#Syntax"
HREF="directive-dict.html#Default"
HREF="directive-dict.html#Context"
HREF="directive-dict.html#Override"
HREF="directive-dict.html#Status"
HREF="directive-dict.html#Module"
HREF="directive-dict.html#Compatibility"
HREF="directive-dict.html#Syntax"
HREF="directive-dict.html#Default"
HREF="directive-dict.html#Context"
HREF="directive-dict.html#Override"
HREF="directive-dict.html#Status"
HREF="directive-dict.html#Module"
HREF="directive-dict.html#Compatibility"
<!--#include virtual="footer.html" -->