How to use the ":1" in irules with HTTP:QUERY?
Hi
I have this irule:
when HTTP_REQUEST {
if { [HTTP::uri] equals "/example1" } {
HTTP:redirect https:// [getfield [HTTP:host] ":" 1 ][HTTP:uri]
}
I found this from some exam questions, how the : work here, does it split the uri or host based on the port number or something?
Couldn't find any doc on the use of : in irules!
Hi DavidMas,
the iRule redirects you to a destination setup by a concatenated string. The portions of the string are https:// followed by the value of [getfield [HTTP:host] ":" 1 ] followed by the original [HTTP:uri] the client has currently requested (e.g. "https://www.domain.de/example1").
The nested [getfield [HTTP:host] ":" 1 ] command extracts at first the [HTTP::host] value from the HTTP request (e.g. could be www.domain.com or www.domain.com:80) and then passes the output to the outer [getfield] command, which then splits the value on each single : character and finally outputs just the first element (e.g. www.domain.com:80 will become www.domain.com) back to the concatenated string.
Cheers, Kai