Forum Discussion

Art_Sholty_6751's avatar
Art_Sholty_6751
Icon for Nimbostratus rankNimbostratus
Oct 29, 2014

Simple iRule failing

I am trying to implement what I thought would be a very simple iRule but I'm unable to get it to process successfully. I am trying to issue a 302 HTTP redirect based on the presence of a specific URI:

 

when HTTP_REQUEST { if { [ string tolower [HTTP::uri]] contains "/httpservices/login/loginService.aspx"} { HTTP::redirect https://login.devstage1.weightwatchers.com/mobilelogin/mobile log local0. "Chassis Redirect" } }

 

Am I misunderstanding how the HTTP redirect function works or am I just making a syntax mistake?

 

3 Replies

  • R_Eastman_13667's avatar
    R_Eastman_13667
    Historic F5 Account

    Because you are comparing a tolower string to a mixed case string, the evaluation will never be true. Change your URI to the below. Notice Service is now service.

    when HTTP_REQUEST { 
            if { [ string tolower [HTTP::uri]] contains "/httpservices/login/loginservice.aspx"} {                HTTP::redirect https://login.devstage1.weightwatchers.com/mobilelogin/mobile 
            log local0. "Chassis Redirect" } 
    }
    
  • You have an upper case S in your "contains", but you've used string tolower. The following is a tad more efficient if you are only concerned with the path, and not the parameters. Also, you should probably scrub your code prior to posting next time:

     

    when HTTP_REQUEST {
      if { [string tolower [HTTP::path]] contains "/httpservices/login/loginservice.aspx"} {
        HTTP::redirect https://login.devstage1.weightwatchers.com/mobilelogin/mobile
        log local0. "Chassis Redirect"
        }
    }

    Eric

     

  • Thanks for the help. I figured this out on my own about a minute after posting, but I appreciate the help. Eric you should feel free to ignore any code you consider to be unscrubbed.