Forum Discussion

pipo_112511's avatar
pipo_112511
Icon for Altostratus rankAltostratus
May 07, 2007

Redirect Https

Hello,

 

 

I'm brand new on Irules,

 

 

I like to know if it's possible to redirect something like that :

 

 

https://www.f5.com

 

 

to

 

 

https://www.f5.com/webpage

 

 

Thanks in advance

7 Replies

  • when HTTP_REQUEST {

     

    if {HTTP::uri eq "/"}{

     

    HTTP::redirect http://[HTTP::host]/webpage

     

    }

     

    }
  • Tanks Kevin,

     

     

    But i've got this error message when i tried to create it

     

     

    01070151:3: Rule [tma] error:

     

    line 2: [parse error: PARSE syntax 28 {syntax error in expression "HTTP::uri eq "/"": variable references require preceding $}] [{HTTP::uri eq "/"}]

     

     

  • Sorry, I didn't review my own post. Try this:

     

     

    when HTTP_REQUEST {

     

    if { [HTTP::uri] equals "/" } {

     

    HTTP::redirect "/webpage"

     

    }

     

    }
  • You need brackets around the HTTP::uri in the if conditional:

     

     

    when HTTP_REQUEST {

     

    if { [HTTP::uri] eq "/" } {

     

    HTTP::redirect http://[HTTP::host]/webpage

     

    }

     

    }

     

     

  • Marcus_Slawik_8's avatar
    Marcus_Slawik_8
    Historic F5 Account
    Thierry,

     

     

    do you use HTTPS in the initiating request or do you want to redirect port 80 to 443? Do you use the BigIP for decryption?

     

     

    schwiddy
  • This is the rule I use for HTTPS Redirect

     

     

    when HTTP_REQUEST {

     

    set userhost [HTTP::host]

     

    HTTP::redirect "https://$userhost[HTTP::uri]"

     

    }