Additional tags are available to use within the Object tag. These tags give you greater flexibility when invoking directives within an object. This section contains the following sections:
The Client tag enables you to limit the execution of a set of directives to requests received from specific clients. Directives listed within the Client tag are executed only when information in the client request matches the parameter values specified.
The following table lists the Client tag parameters.
Table 6–1 Client Tag Parameters
The Client tag parameter provides greater control when the If directive is executed. In the following example, use of the odds parameter gives the request a 25% chance of being redirected:
<Client odds="25%"> NameTrans fn="redirect" from="/Pogues" url-prefix="http://pogues.example.com" </Client>
One or more wildcard patterns can be used to specify the Client tag parameter values. Wildcards can also be used to exclude clients that match the parameter value specified in the Client tag. In the following example, the Client tag and the AddLog directive are combined to direct the Web Server to log access requests from all clients except those from the specified subnet:
<Client ip="*~192.85.250.*"> AddLog fn="flex-log" name="access" </Client>
You can also create a negative match by setting the match parameter of the Client tag to none. In the following example, access requests from the specified subnet are excluded as are all requests to the virtual server sun.com:
<Client match="none" ip="192.85.250.*" urlhost="www.sun.com"> AddLog fn="flex-log" name="access" </Client>
For more information about wildcard patterns, see Appendix B, Using Wildcard Patterns.
The If, ElseIf, and Else tags enable you to define the conditions under which to execute a set of directives. Like the Client tag, these tags can only appear inside an Object tag. In addition, these tags can evaluate an expression, then conditionally execute one or more contained directives. However, there are some key differences between the these tags and the Client tag, as summarized below:
If and ElseIf tags offer a richer expression syntax, including support for regular expressions. This expression syntax is different from the Client syntax. For more information on the If and ElseIf expression syntax, see Expressions.
If, ElseIf, and Else tags can contain other tags.
If and ElseIf expressions are evaluated once per request, not once per contained directive.
If, ElseIf, and Else tags cannot contain multiple types of directives.
Directives within the If and ElseIf tags can contain regular expression backreferences.
When used, an ElseIf or Else tag must immediately follow an If or ElseIf tag. ElseIf and Else tags are skipped if the preceding If or ElseIf expression evaluates to logical true.
The following example shows If, ElseIf, and Else tag syntax:
<If $path eq "/"> <If $browser =~ "MSIE"> NameTrans fn="rewrite" path="/msie.html" </If> <ElseIf $browser =~ "Mozilla"> NameTrans fn="rewrite" path="/mozilla.html" </ElseIf> <Else> NameTrans fn="rewrite" path="/unknown.html" </Else> </If>
This example presents a different page based on whether the browser is Microsoft Internet Explorer, Mozilla, or another browser.