F5 is upgrading its customer support chat feature on My.F5.com. Chat support will be unavailable from 6am-10am PST on 1/20/26. Refer to K000159584 for details.

Forum Discussion

Gurinder_Singh_'s avatar
Gurinder_Singh_
Icon for Nimbostratus rankNimbostratus
Oct 27, 2014

Nedd help with https redirect

Hello Guys,

 

I need help with iRule.. I have created specific ip for redirection for my web site from http to https (even if contain IP).

 

Here what I did

 

when HTTP_REQUEST { if { [HTTP::host] contains "xyz.com" or "10.x.x.x" or "1x.x.x.x" } { HTTP::redirect https://www.xyz.com } }

 

When user send request to http://xyz.com redirection works fine. But if user try https://xyz.com/test (or anything after /) it’s redirecting back to https://www,xyz.com home page.

 

Is there a way to define rule so redirect with requested url ?

 

Thanks, GSingh

 

5 Replies

  • shaggy's avatar
    shaggy
    Icon for Nimbostratus rankNimbostratus

    when HTTP_REQUEST { if { [HTTP::host] contains "xyz.com" or "10.x.x.x" or "1x.x.x.x" } { HTTP::redirect https://www.xyz.com[HTTP::uri] } }

     

  • Thanks Shaggy..but it's still redirecting back to home page.

     

    here is what is did

     

    when HTTP_REQUEST { if { [HTTP::host] contains "xyz.com" or "10.x.x.x" or "1x.x.x.x" } { HTTP::redirect https://www.xyz.com[HTTP::uri] } }

     

    let me know if i am doing it right?

     

    Thanks, GSingh

     

    • shaggy's avatar
      shaggy
      Icon for Nimbostratus rankNimbostratus
      The redirect portion looks correct, but the if statement looks off: if { [HTTP::host] contains "xyz.com" or [HTTP::host] contains "10.x.x.x" or [HTTP::host] contains "1x.x.x.x" }
  • Fix the statement, But still no luck .. redirecting back home page (https://www.xyz.com)

     

    when HTTP_REQUEST { if { [HTTP::host] contains "xyz.com" or [HTTP::host] contains "10.x.x.x" or [HTTP::host] contains "1x.x.x.x" } { HTTP::redirect https://www.xyz.com[HTTP::uri] } }

     

    • shaggy's avatar
      shaggy
      Icon for Nimbostratus rankNimbostratus
      Is a subsequent redirect coming from the server? I use this syntax often in iRules and have no issues (see the _sys_https_redirect iRule for an example of an f5-supplied iRule using the syntax). Have you tried testing from curl or another client that will show you exactly what is coming back from the F5?