Forum Discussion

BM_27231's avatar
BM_27231
Icon for Nimbostratus rankNimbostratus
Jul 11, 2011

URL based redirection using irules is not working

Hi,

 

 

I have problem in my F5 irules the scenario is as follows, appreciate your help in this issue

 

 

 

Http://Dev.abc.com/TEST is my primary URL in this /TEST is the contest root redirected by web server now my requirement is when F5 gets request for a URI "/TEST/Maddy" it has to go to a different pool. I have created rule as follows but it is not redirecting for the "/TEST/Maddy"

 

 

 

when HTTP_REQUEST {

 

if { ([HTTP::uri] contains "/TEST/maddy")}{

 

pool web_maddy_pool_port_9001

 

}

 

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

 

HTTP::redirect "http://dev.abc.com/TEST"

 

} else {

 

pool Development_TEST_pool_port_7789

 

}

 

}

 

 

 

 

Web_maddy_pool_port_9001 - has IPs of weblogic cluster for Maddy pool

 

 

 

Development_TEST_pool_port_7789 - has IPs of weblogic cluster for default pool

 

 

 

Appreciate your help

 

3 Replies

  • The last sentence of your explanation says "it is not redirecting for the "/TEST/Maddy"". Is it possible that the problem is just case sensitivity?

     

     

    Your iRule code has the following test...

     

    if { ([HTTP::uri] contains "/TEST/maddy")}{

     

     

    Note the lowercase "m" in the code, but the uppercase "M" in your explanation.
  • You could do something like what I have below.

    When doing it this way the item in the switch statement is absolute, so what I have below "/test/maddy/*" contains the wildcard so that this would equal { [HTTP::uri] starts_with "/test/maddy" }.

    This should also make it easier to add to in the future.

    
    when HTTP_REQUEST {
    switch -glob [string tolower [HTTP::uri]] {
    "/" { HTTP::redirect "http://dev.abc.com/test" }
    "/test/maddy/*" { pool web_maddy_pool_port_9001 }
    default { pool Development_TEST_pool_port_7789 }
    }
    }
    
  • Thank you

     

     

     

    i think we have kind of identified the issue, but session stickiness is making issues. Anybody has though on overwriting and dropping the cookies?