Previous Topic: Regular Expression Examples in nete:rule and nete:result

Next Topic: Regular Expressions to Redirect Users

Map Single Rule to Many Destination Servers

In the following example, a nete:rule element contains a regular expression that can be used to forward requests to many different destinations. This example assumes that the SPS will receive URIs that take the following form:

/GOTO=some path and or filename

Consider a nete:xprcond element contains the following child elements:

<nete:xpr>
<nete:rule>/GOTO=(.*)/(.*)</nete:rule>
<nete:result>http://$1/$2</nete:result>
</nete:xpr>

The regular expression in the nete:rule element and the associated nete:result element match URIs that produce a /GOTO=string. Upon finding a match, the SPS uses the first string after the = symbol in the URI as the $1 value of the result, and the value following the first / symbol that appears after the = symbol as the $2 result. The nete:result element combines these elements to create a URL. By default, nete:result elements use the SPS forward service.

For example, if the URI of a request evaluated by the nete:xpr element described above were as follows:

/GOTO=server1.company.com/index.html

Then the regular expression in the nete:rule element would find a match and assign the value of $1 as server1.company.com and the value of $2 as index.html. The nete:result element assembles these values into the following URL:

http://server1.company.com/index.html

This URL is the target which the SPS uses to resolve the request.