Name
BrowserMatch and BrowserMatchNoCase
Synopsis
BrowserMatchregex
env1
[=value1
]env2
[=value2
]...
BrowserMatchNoCaseregex
env1
[=value1
]env2
[=value2
] ... Server config, virtual host, directory, .htaccess (from Apache v 1.3.14)
regex
is a regular expression matched
against the client’s User-Agent
header, and env1
,
env2
, ... are environment variables to be
set if the regular expression matches. The environment variables are
set to value1
,
value2
, etc., if present.
So, for instance, we might say:
BrowserMatch ^Mozilla/[23] tables=3 java
The symbol ^ means start from the beginning of the header and match
the string Mozilla/
followed by either a
2
or 3
. If this is successful,
then Apache creates and, if required, specifies values for the given
list of environment variables. These variables are invented by the
author of the script, and in this case they are:
tables=3 java
In this CGI script, these variables can be tested and take the appropriate action.
BrowserMatchNoCase
is simply a case-blind version
of BrowserMatch
. That is, it
doesn’t care whether letters are upper- or
lowercase. mOZILLA
works as well as
MoZiLlA
.
Note that there is no difference between
BrowserMatch
and SetEnvIf
User-Agent
. BrowserMatch
exists
for backward compatibility.
Get Apache: The Definitive Guide, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.