Forum Discussion

F5user13_114603's avatar
Aug 14, 2016

Https redirection only works for root domain and not for virtual directories

Hi,

 

I have an issue where in the http to https redirection works for the root domain and fails to work for the virtual directories.

 

Example: http://example.com gets redirected to https://example.com but http://example.com/default.aspx does not redirect to https://example.com/default.aspx

 

Please help.

 

1 Reply

  • This would be a simple iRule for such a redirection:

    when HTTP_REQUEST {
    HTTP::respond 301 Location "https://[HTTP::host][HTTP::uri]"
    }
    

    Similar redirection but after checking the domain:

    when HTTP_REQUEST {
    if { [HTTP::host] eq "example.com" } {
    HTTP::respond 301 Location "https://[HTTP::host][HTTP::uri]"
    }
    }
    

    For LTM Policies: Under the Parameters operand, type the following text in the box:

      https://[getfield [HTTP::host] ":" 1][HTTP::uri]
    

    SOL14996