Forum Discussion

N_67263's avatar
N_67263
Icon for Nimbostratus rankNimbostratus
Sep 29, 2013

need help with a iRule.

Folks,

 

I need to work on a iRule which accepts a request on http and forward a particular page to http only. All other are redirected on https. e.g. http://testsite.com/support/Lic --> http://testsite.com/support/Lic http://testsite.com/* --> https://testsite/com/* (default)

 

Regards, Nikhil.

 

3 Replies

  • The approach will be to to filter the matching HTTP::host and HTTP::path and to use a pool. In case of no match a redirect applies.

     

    Make sure to use a 'string tolower' to compensate varying cases.

     

    There is another option to cover the query part of the URI as well (the stuff after the question mark). The full URI (containing both the path and separated query) will be used in combination with the original hostname for a redirect to https by using the following sample code:

     

    when HTTP_REQUEST {
        if {([string tolower [HTTP::host]] eq "testsite.com") && ([string tolower [HTTP::path]] eq "/support/lic")}
            pool pool_of_licservers
        } else {
            HTTP::redirect https://[HTTP::host][HTTP::uri]
        }
    }
  • Alternatively can be achieved using below.

     

    when HTTP_REQUEST { if { [HTTP::uri] contains "/support/Lic"}{ HTTP::redirect "http://testsite.com/support/Lic" } else { HTTP::redirect "https://[HTTP::host][HTTP::uri]" } }