Forum Discussion

Basil_Parsley_1's avatar
Basil_Parsley_1
Icon for Nimbostratus rankNimbostratus
Aug 22, 2016

Irule - HTTP redirect with a rewrite.

Guys,   I have a HTTP(S) redirect requirement ; I am migrating Apache load balancer webservices to F5.   The requirement is to redirect   https://webname.com/aaa/Default.aspx?ID:CUST=123 ...
  • Hannes_Rapp_162's avatar
    Aug 22, 2016

    Append

    ?[HTTP::query]
    to your redirect destination (sample below). The only problem with this approach is that you will always be redirected to a location with ?-symbol at the end, whether you have any query parameters in the original request or not.

    HTTP::respond 302 Location "https://webname.com/bbb/default.aspx?[HTTP::query]"
    

    If the above bothers you, you can write a condition to determine if the question mark should be appended or not as follows

     Determine if original request contains query parameters
    if { [HTTP::query] ne "" }{
      set myQuery "?[HTTP::query]"
    } else {
      set myQuery ""
    }
     your condition goes here
    HTTP::respond 302 Location "https://webname.com/bbb/default.aspx$myQuery"