19.29 mod_setenvif

Team-Fly    

 
Webmaster in a Nutshell, 3rd Edition
By Robert Eckstein, Stephen Spainhour
Table of Contents
Chapter 19.  Apache Modules

19.29 mod_setenvif

The mod_setenvif module sets environment variables based on the client's browser or other information.

BrowserMatch

  BrowserMatch   regex  var[  =value  ] var[  =value  ] ... 

[ server config ]

Sets environment variables based on the client's browser type. If the User -Agent HTTP header matches the regular expression specified by regex , set one or more environment variables as follows :

var

The environment variable is defined and given the value of 1.

!var

The environment variable is deleted.

var=value

The environment variable is set to an initial value.

Here is an example of how to locate various browsers. The first sets compatible if the client is connecting with Versions 2 through 4 of Netscape. The second sets microsoft if Internet Explorer is detected :

 BrowserMatch ^Mozilla/[2-4] compatible !microsoft BrowserMatch MSIE microsoft 
BrowserMatchNoCase

 BrowserMatchNoCase  regex var=value var=value ...  

[ server config ]

Identical to BrowserMatch, except that matching is now case-insensitive. For example, the following would still work to detect Internet Explorer:

 BrowserMatch msie microsoft 
SetEnvIf

  SetEnvIf   attribute  regex var[  =value  ] var[  =value  ] 

[ server config ]

Sets environment variables based on the attributes of an HTTP request. Some of the more common attributes are:

Remote_Host

The hostname of the client, if known

Remote_Addr

The IP address of the client

Remote_User

The user which is making the request, if known

Request_Method

The name of the HTTP method being used to request information

Request_URI

The latter portion of the URL, after the host information

Referer

The URI of the referring page, if known

For example, the following sets the environment variable SOMEONE_FROM_OREILLY if the remote host resolves to the domain oreilly.com :

 SetEnvIf Remote_Host oreilly.com SOMEONE_FROM_OREILLY 
SetEnvIfNoCase

  SetEnvIfNoCase   attribute  regex var[  =value  ] var[  =value  ] 

[ server config ]

Identical to SetEnvIf, except that attribute matching is now case-insensitive.


Team-Fly    
Top


Webmaster in a Nutshell
Webmaster in a Nutshell, Third Edition
ISBN: 0596003579
EAN: 2147483647
Year: 2002
Pages: 412

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net