Forum Discussion

Thomas_Lam's avatar
Thomas_Lam
Icon for Nimbostratus rankNimbostratus
Mar 14, 2016

starts_with Not working

Hi there,

the target url is "https://portal.abc.com/store/register.aspx?lang=en"

I tried to redirect the page when hit the above url with below irule, but it didn't work.

when HTTP_REQUEST { if { [string tolower [HTTP::uri]] starts_with "/store/register.aspx" } {

HTTP::respond 200 content "It works"

} }

However, if I tried below by replacing "starts_with" to "contains", it somehow works, but this is not I want.

when HTTP_REQUEST { if { [string tolower [HTTP::uri]] contains "register.aspx" } {

HTTP::respond 200 content "It works"

} }

My F5 version is "BIG-IP 10.2.2 Build 852.0 Hotfix HF1".

Thanks.

3 Replies

  • Have you tried adding some logging, so you can see what [HTTP::uri] is? Have you tried adding some logging, so you can see what [HTTP::uri] is? when HTTP_REQUEST { if { [string tolower [HTTP::uri]] contains "register.aspx" } { log local0. "HTTP::URI: [HTTP::uri]" HTTP::respond 200 content "It works" } } This will log on /var/log/ltm
  • Have you tried adding some logging, so you can see what [HTTP::uri] is?

    when HTTP_REQUEST {
      if { [string tolower [HTTP::uri]] contains "register.aspx" } { 
        log local0. "HTTP::URI: [HTTP::uri]"
        HTTP::respond 200 content "It works" 
      }
    } 
    

    This will log on /var/log/ltm

  • Thanks John. I have added the logging, and it shows as below. It seems the HTTP::uri is returned as expected, but somehow I'm not sure if the "starts_with" is not working properly, or somewhere I missed out. Thanks.

     

    Rule Testing_Block : HTTP::URI: /store/register.aspx?lang=en