Forum Discussion

Anthony_Vaz_547's avatar
Anthony_Vaz_547
Icon for Nimbostratus rankNimbostratus
May 02, 2006

I'm really confused

Hi guys

 

Sorry this should be really simple, but I just can;t get it.

 

 

Basically - I am trying to setup a redirection rule.

 

 

What I want is, when a request comes in to a virtual server, and the URI is "/", I want the irule to interrogate the request, if there is a cookie called "LtpaToken", then go to pageA, but if the URI is "/" and there is no cookie called "LtpaToken", I want the Irule to redirect to Page B.

 

 

And I'm tying myself up in knots.

 

 

This is the closest I have got (and I know I'm miles away)

 

 

when HTTP_REQUEST {

 

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

 

if {[HTTP::cookie exists LtpaToken] } {

 

HTTP::redirect "http://[HTTP::host]/wps/myportal"

 

} else {

 

HTTP::redirect "http://[HTTP::host]/wps/portal"

 

 

} else {

 

 

return

 

}

 

}

 

 

 

 

Should HTTP::cookie be available when I'm using HTTP_REQUEST? Can anyone help point me in the right direction?

 

 

Cheers
  • This looks good to me except that you have two else statements right next to eachother.

    I'd try this:

    when HTTP_REQUEST {
      if { [HTTP::uri] equals "/" } {
        if { [HTTP::cookie exists LtpaToken] } {
          HTTP::redirect "http://[HTTP::host]/wps/myportal"
        } else {
          HTTP::redirect "http://[HTTP::host]/wps/portal"
        }
      }
    }

    Have you determined what exactly your problem is? I'd try throwing in some log statements to find out what's going on.

    when HTTP_REQUEST {
      log local0. "URI is [HTTP::uri]"
      if { [HTTP::uri] equals "/" } {
        if { [HTTP::cookie exists LtpaToken] } {
          log local0. "Cookie LtpaToken exists, redirecting to http://[HTTP::host]/wps/myportal"
          HTTP::redirect "http://[HTTP::host]/wps/myportal"
        } else {
          log local0. "Cookie LtpaToken does not exist, redirecting to http://[HTTP::host]/wps/portal"
          HTTP::redirect "http://[HTTP::host]/wps/portal"
        }
      }
    }

    Then take a look at the /var/log/ltm file on the BIG-IP to find out what's going on.

    -Joe