Forum Discussion

David_M's avatar
David_M
Icon for Cirrostratus rankCirrostratus
Jun 24, 2019

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 questi...
  • Kai_Wilke's avatar
    Jun 24, 2019

    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