The
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 netscape
if the
browser is mozilla but not MSIE.
When the server looks up a path via an internal
A regular expression only needs quoting when it contains space,
in which case single and double quotes are equivalent. Unlike
\\
requires \\\
, and \\\
requires
\\\\\
.
The User-Agent
HTTP request header. The following two
lines have the same effect:
Some additional examples:
The
The
The
Host
,
User-Agent
, Referer
, and
Accept-Language
. A regular expression may be
used to specify a set of request headers.Remote_Host
- the hostname (if available) of
the client making the requestRemote_Addr
- the IP address of the client
making the requestServer_Addr
- the IP address of the server
on which the request was received (only with versions later
than 2.0.43)Request_Method
- the name of the method
being used (GET
, POST
, et
cetera)Request_Protocol
- the name and version of
the protocol with which the request was made (e.g.,
"HTTP/0.9", "HTTP/1.1", etc.)Request_URI
- the resource requested on the HTTP
request line -- generally the portion of the URL
following the scheme and host portion without the query string. See
the SetEnvIf[NoCase]
directives are available for testing in
this manner. 'Earlier' means that they were defined at a broader scope
(such as server-wide) or previously in the current directive's scope.
Environment variables will be considered only if there was no match
among request characteristics and a regular expression was not
used for the attribute.The second argument (regex) is a
The rest of the arguments give the names of variables to set, and optionally values to which they should be set. These take the form of
varname
, or!varname
, orvarname=value
In the first form, the value will be set to "1". The second
will remove the given variable if already defined, and the
third will set the variable to the literal value given by
value
. Since version 2.0.51, Apache httpd will
recognize occurrences of $1
..$9
within
value and replace them by parenthesized subexpressions
of regex. $0
provides access to the whole
string matched by that pattern.
If the special value --early
is specified, and this
directive is not in directory context, the directive will be evaluated
earlier during request processing. This allows the output variables
set by this directive to be used as input to the "early mode" option of
the
The first three will set the environment variable
object_is_image
if the request was for an image
file, and the fourth sets intra_site_referral
if
the referring page was somewhere on the
www.mydomain.example.com
Web site.
The last example will set environment variable
HAVE_TS
if the request contains any headers that
begin with "TS" whose values begins with any character in the
set [a-z].
The
This would set the environment variable iso_delivered
every time our application attempts to send it via X-Sendfile
A more useful example would be to set the variable rfc1918 if the remote IP address is a private address according to RFC 1918:
The
This will cause the site
environment variable
to be set to "example
" if the HTTP request header
field Host:
was included and contained
Example.Org
, example.org
, or any other
combination.