Apache Reference: mod_setenvif, SetEnvIf

SetEnvIf

Define Environment Variables Based on HTTP Attributes
Syntax: SetEnvIf attribute pattern [!]var[=val] [...]
Example: SetEnvIf Request_URI ".*\.gif$" isgif
Since: Apache 1.3

This directive defines environment variables based on attributes of the HTTP request. The attribute arguments can take on the values of various HTTP request header fields (see RFC 2068 for more information) or other aspects of the request. For example, the following values are valid: ``Remote_Host'' for the host name (if available) of the client making the request; ``Remote_Addr'' for the IP address of the client making the request; ``Remote_User'' for the authenticated user name (if available); ``Request_Method'' for the name of the method being used (such as GET or POST); ``Request_Protocol'' for the name and version of the protocol with which the request was made (such as ``HTTP/0.9'' or ``HTTP/1.1'') or ``Request_URI'' for the portion of the URL following the scheme and host portion.

Some of the more commonly used request header field names include ``Host'', ``User-Agent'', and ``Referer''. If the attribute doesn't match any of the special keywords or any of the request's header field names, it is tested to see whether it matches the name of an environment variable in the list of those associated with the request. SetEnvIf directives can therefore test it against the result of prior matches. Only those environment variables defined by earlier SetEnvIf or SetEnvIfNoCase directives are available for testing in this manner; that is, these variables must have been defined at a broader scope (such as server-wide) or previously in the current directive's scope.