Hitachi

Hitachi Application Server V10 Definition Reference Guide (For UNIX® Systems)


2.3.140 SetEnvIf

SetEnvIf defines an environment variable based on the request from a client.

Description

SetEnvIf sets specified environment variables when the value of the request from a client meets conditions specified by a regular expression.

Syntax

SetEnvIf request_value regular_expression environment_variable[=value] [environment_variable[=value] ...]

Specifiable values

request_value

You can specify the HTTP request header or the values listed in the table below.

The SetEnvIf directive enables you to check the environment variable specified in request_value, by specifying the environment variable of the directive specified earlier in the file, into the request value. However, in this case, the environment variable must not correspond to the HTTP request header or to the values listed in the table below.

Request values

Meanings

Remote_Addr

IP address of the client

Remote_Host

Host name of the client (only if specified in the request)

Request_Protocol

Protocol of the request (such as HTTP/1.1)

Request_Method

Method name of the request (such as GET, POST, or HEAD)

Request_URI

URI of the request

Server_Addr

IP address of the server that received the request

If you specify this directive more than once, you cannot specify the same request value more than once.

However, if you specify Remote_Host for the request value, you can specify a host name corresponding to an IPv6 address for the regular expression. In addition, you cannot use the request value Remote_Addr or Server_Addr for a connection using IPv6. If you want to use Remote_Addr or Server_Addr, specify them by using the HWSSetEnvIfIPv6 directive.

regular_expression

Specify conditions.

environment_variable

Specify the environment variable to be set when the value of a request from a client meets the conditions specified by the regular expression.

Adding ! before an environment variable disables the environment variable.

values

Specify the value for the environment variable.

The default value is 1.

Locations where it can be written

httpsd.conf, <VirtualHost>, <Directory> and .htaccess

Overwrite permission

FileInfo level

Examples

Example 1:
SetEnvIf User-Agent "Mozilla.*" SETENVIF_USER_AGENT=Mozilla
Example 2:
SetEnvIf Request_URI "\.(gif)|(jpg)$" request_is_image
Example 3:

This example sets an environment variable for a specific client, from among the connections that use IPv4:

Listen 123.123.123.123:80
Listen [2001::123:4567:89ab:cdef]:80
<VirtualHost 123.123.123.123:80>
        SetEnvIf Remote_Addr ^234\.234\.234\.234$ IPV4_CLIENT
</VirtualHost>