Forum Discussion

Jim_Couch_16225's avatar
Jim_Couch_16225
Icon for Nimbostratus rankNimbostratus
Sep 25, 2018

Http > Https redirect with a modification to the URL.

I tried using the default http > https url redirect on an application yesterday but when I would redirect, the application would break. Turns out, there is code built into the application that specifics a port number and so what I think is happening is http://www.application.com:80 is being redirected to https://www.application.com:80 so trying https over port 80. How could I modify the iRule so that it rewrites the URL to eliminate the port :80 part? The application owner said he might be able to modify it in their code, but I would like a back up plan.

 

  • The system iRule "_sys_https_redirect" should do that for you.

    It uses "HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri]".

    From the documentation:

    https://devcentral.f5.com/wiki/irules.getfield.ashx

    To extract only the hostname from the host header (strips any trailing ":" port specification)

    when HTTP_REQUEST {
      set hostname [getfield [HTTP::host] ":" 1]
    }