Previous Topic

Next Topic

Book Contents

Book Index

Server Variables

Using the [V=] flag you can achieve some sophisticated URI rewrite functionality. Instead of the URI string, the value of the server variable will be matched. Use with [C] flags and usually without the URI rewrite- thus with "-" for destination only.

Supported variables are the general HTTP_* variables: HTTP_HOST, HTTP_REFERER, HTTP_USER_AGENT, THE_REQUEST, REMOTE_IP.

^(www\.myhost\.com)?$ - [V=HTTP_HOST,C]

Virtual host is checked for "www.myhost.com".

The V= flag will be usually used with the [C] chained flag as a predecessor, such as in the following rewrite rule.

^/webmail/ - [C]

^Lynx/ /mail/ [V=HTTP_USER_AGENT,C,R]

The example above would match the /webmail/ in the URL (not replace anything) then it would check if the HTTP_USER_AGENT contains Lynx/ and if it does, redirect to /mail/. Lynx web browser simply cannot go to /webmail/ and will be redirected to /mail/

Very flexible!

See Also

Re-Write Tutorial

Differences

Directory Aliases - Absolute Path

Directory Aliases - Relative Path

Non RegEx Rewrites

RegEx Rewrites

Flags