From: Joshua Slive Date: Sun, 26 May 2002 23:10:15 +0000 (+0000) Subject: A little refactoring of the mod_setenvif docs. In particular, consolidate the X-Git-Tag: 2.0.37~252 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=45c6635d19ec49f60f0d6add1d6d086acba7c325;p=thirdparty%2Fapache%2Fhttpd.git A little refactoring of the mod_setenvif docs. In particular, consolidate the details in the SetEnvIf directive and let the others simply reference that one. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@95296 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/docs/manual/mod/mod_setenvif.xml b/docs/manual/mod/mod_setenvif.xml index 8ff6b36e3aa..d0677678925 100644 --- a/docs/manual/mod/mod_setenvif.xml +++ b/docs/manual/mod/mod_setenvif.xml @@ -9,7 +9,6 @@ on characteristics of the request Base mod_setenvif.c setenvif_module -Available in Apache 1.3 and later @@ -37,63 +36,30 @@ on characteristics of the request BrowserMatch Sets environment variables conditional on HTTP User-Agent -BrowserMatch regex env-variable[=value] -[env-variable[=value]] ... +BrowserMatch regex [!]env-variable[=value] +[[!]env-variable[=value]] ... server config virtual hostdirectory .htaccess FileInfo -Apache 1.2 and - above (in Apache 1.2 this directive was found in the - now-obsolete mod_browser module) -

The BrowserMatch directive defines - environment variables based on the User-Agent HTTP - request header field. The first argument should be a POSIX.2 - extended regular expression (similar to an - egrep-style regex). 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

- -
    -
  1. varname, or
  2. - -
  3. !varname, or
  4. - -
  5. varname=value
  6. -
- -

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 value given by - value. If a User-Agent - string matches more than one entry, they will be merged. - Entries are processed in the order in which they appear, and - later entries can override earlier ones.

+

The BrowserMatch is a special cases of the + SetEnvIf directive that + sets environment variables conditional on the + User-Agent HTTP request header. The following two + lines have the same effect:

+ + BrowserMatchNoCase Robot is_a_robot
+ SetEnvIfNoCase User-Agent Robot is_a_robot
+
-

For example:

+

Some additional examples:

BrowserMatch ^Mozilla forms jpeg=yes browser=netscape
BrowserMatch "^Mozilla/[2-3]" tables agif frames javascript
BrowserMatch MSIE !javascript
- -

Note that the regular expression string is - case-sensitive. For case-INsensitive matching, - see the BrowserMatchNoCase - directive.

- -

The BrowserMatch and - BrowserMatchNoCase directives are special cases of - the SetEnvIf and SetEnvIfNoCase - directives. The following two lines have the same effect:

- - BrowserMatchNoCase Robot is_a_robot
- SetEnvIfNoCase User-Agent Robot is_a_robot
-
@@ -101,8 +67,8 @@ on characteristics of the request BrowserMatchNoCase Sets environment variables conditional on User-Agent without respect to case -BrowserMatchNoCase regex env-variable[=value] - [env-variable[=value]] ... +BrowserMatchNoCase regex [!]env-variable[=value] + [[!]env-variable[=value]] ... server config virtual hostdirectory .htaccess @@ -140,24 +106,28 @@ respect to case Sets environment variables based on attributes of the request SetEnvIf attribute - regex env-variable[=value] - [env-variable[=value]] ... + regex [!]env-variable[=value] + [[!]env-variable[=value]] ... server config virtual hostdirectory .htaccess FileInfo -Apache 1.3 and - above; the Request_Protocol keyword and environment-variable - matching are only available with 1.3.7 and later -

The SetEnvIf directive defines environment - variables based on attributes of the request. These attributes - can be the values of various HTTP request header fields (see The SetEnvIf directive defines + environment variables based on attributes of the request. The + attribute specified in the first argument can be one of three + things:

+ +
    +
  1. An HTTP request header field (see RFC2616 - for more information about these), or of other aspects of the - request, including the following:

    + for more information about these); for example: Host, + User-Agent, Referer, and + Accept-Language. A regular expression may be + used to specify a set of request headers.
  2. +
  3. One of the following aspects of the request:
    • Remote_Host - the hostname (if available) of the client making the request
    • @@ -176,34 +146,46 @@ respect to case the protocol with which the request was made (e.g., "HTTP/0.9", "HTTP/1.1", etc.) -
    • Request_URI - the portion of the URL - following the scheme and host portion
    • +
    • 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
    +
  4. + +
  5. The name of an environment variable in the list of those +associated with the request. This allows +SetEnvIf directives to test against the result +of prior matches. Only those environment variables defined by earlier +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.
  6. +
+ +

The second argument (regex) is a Perl compatible regular expression. +This is similar to a POSIX.2 egrep-style regular expression. +If the regex matches against the attribute, +then the remainder of the arguments are evaluated.

+ +

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

+ +
    +
  1. varname, or
  2. -

    Some of the more commonly used request header field names - include Host, User-Agent, and - Referer.

    - -

    If the attribute name doesn't match any of the - special keywords, nor any of the request's header field names, - it is tested as the name of an environment variable in the list - of those associated with the request. This allows - SetEnvIf directives to test against the result of - prior matches.

    - - - Only those environment variables defined by earlier - 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. - - -

    attribute may be a regular expression when used to - match a request header. If attribute is a regular - expression and it doesn't match any of the request's header - names, then attribute is not tested against the - request's environment variable list.

    +
  3. !varname, or
  4. + +
  5. varname=value
  6. +
+ +

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.

Example: @@ -235,8 +217,9 @@ respect to case SetEnvIfNoCase Sets environment variables based on attributes of the request without respect to case -SetEnvIfNoCase attribute regex env-variable[=value] - [env-variable[=value]] ... +SetEnvIfNoCase attribute regex + [!]env-variable[=value] + [[!]env-variable[=value]] ... server config virtual hostdirectory .htaccess