Forum Discussion
Mar 23, 2009
TCL is pretty specific about where you put curly braces and the else statement. I think what the issue is is the two sets of statements (snat and pool) between the "if" and "else". Also, A URL is the form of "protocol:[HTTP::host][HTTP::uri]" so you should leave out the ws.digiticalrecordcenter.com out of the comparison. Also, I prefer to use a switch statement as it's a little better performing than an if.
Give this a shot:
when HTTP_REQUEST {
switch [string tolower [HTTP::uri] {
"/crossdomain.xml" {
snat 10.195.3.162
pool POOL_WS.DRC.COM_EN
}
default {
HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri]
}
}
}
Another bonus with switch, is that you can use "glob" based wildcards which are faster than regular expressions. So, if you wanted to match based on a pattern you could do something like this:
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::uri] {
"/*.xml" {
snat 10.195.3.162
pool POOL_WS.DRC.COM_EN
}
default {
HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri]
}
}
}
If you want to go the "if" route, it would look like this.
when HTTP_REQUEST {
if { [string tolower [HTTP::uri] equals "/crossdomain.xml" } {
snat 10.195.3.162
pool POOL_WS.DRC.COM_EN
} else {
HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri]
}
}
One more thing. You didn't mention in your requirements that you needed to snat the connection. What's the reason for including the "snat 10.195.3.162" statement? If a snat is not needed, you might want to leave that one out.
Hope this helps...
-Joe