Hitachi

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


2.3.120 RedirectMatch

RedirectMatch redirects the requests from clients that meet conditions specified by using regular expressions.

Description

RedirectMatch redirects the requests sent from clients to paths that meet conditions specified by using regular expressions to a new path.

When the regular expression in regular_expression is surrounded by parentheses (()), you can specify $n (where n is a number from 1 to 9) which indicate the character string matching the nth regular expression in the regular_expression. For example, $1 indicates the first group, and $2 indicates the second group. The specified status code and the Location header that have the new path set are returned as responses when a request to the path that meets conditions specified by regular expressions is received. Generally, the web browser that received status codes of the 300-series automatically sends the request again (redirects) to the address specified in the Location header.

Syntax

RedirectMatch [{permanent|temp|seeother|gone|status_code}] regular_expression new_path

Specifiable values

permanent

Specify this value if you want to send the status code 301 Moved Permanently.

temp

Specify this value if you want to send the status code 302 Found.

seeother

Specify this value if you want to send the status code 303 See Other.

gone

Specify this value if you want to send the status code 410 Gone. You cannot specify new_path.

status_code

Specify this value if you want to send the specified status code.

Note that, if a status code other than a 300-series status code is specified, you cannot specify new_path.

regular_expression

Specify the URL path of an old request that begins with a slash mark (/), in regular expressions. Note that, for old_path, you cannot specify the path after ? (an inquiry string).

The specification for old_path cannot be the same as the value specified in the following directive:

  • path_name_specified_for_ProxyPass

For example, the following specification cannot be made:

RedirectMatch ^/aaa/bbb/(.*) http://aaa.example.com/$1
ProxyPass /aaa/ http://aaa.example.com/
new_path

Specify a path of a URL that includes protocol_name://host_name[:port_number]. For the URL to be specified as new_path, you can also specify an IPv6 address or a host name that corresponds to the IPv6 address.

Locations where it can be written

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

Overwrite permission

FileInfo level

Examples

Example 1:
RedirectMatch ^/other/ http://www.example.com/

All requests starting with /other/ are redirected to http://www.example.com/ with the status code 302.

Example 2:
RedirectMatch permanent ^/old/(.*) http://www.example.com/new/$1

Requests to /old/file_name are redirected to http://www.example.com/new/file_name with the status code 301.