Forum Discussion

Joe_Pipitone's avatar
Joe_Pipitone
Icon for Nimbostratus rankNimbostratus
Jul 20, 2009

Simple HTTP Redirection - case sensitive?

Hello all,

 

I am running Big-IP 9.4.7.

 

 

I currently have a variety of redirects in place using string match, however if a user types a URI in upper case, the iRule doesn't work. Can anyone tell me what the easiest method of string matching would be? Here's an example of what I have now - as you can see, I had to create 2 separate if statements to catch both instances, but there could also be times when Membership was capitalized, when renew was not:

 

when HTTP_REQUEST {

 

if { [string match "*website.org/Membership/Renew" "[HTTP::host][HTTP::uri]"] } {

 

HTTP::redirect "https://www.website.org/Membership/Renewform.aspx"

 

}

 

if { [string match "*website.org/membership/renew" "[HTTP::host][HTTP::uri]"] } {

 

HTTP::redirect "https://www.website.org/Membership/Renewform.aspx"

 

}

 

}

 

I've read an article about using a string related iRule? Can I use something like that for this example? I'd have to match the host name as well (website.org)

 

Thank you for any help!

2 Replies

  • Hi,

    Just use the "string tolower" command to perform the matches. But you'll have to split the host and URI if you really need to check the host. If "website.org" isn't going to change then just this should work:

      
     when HTTP_REQUEST {  
     if { [string tolower [HTTP::uri]] eq "/membership/renew" } {  
     HTTP::redirect "https://www.website.org/Membership/Renewform.aspx"  
     }   
     

    Otherwise you'll need another "if" statement to check [HTTP:host] using the same logic as well.

    Denny
  • Thanks - with some modification I was able to get your rule working - I appreciate your help!

    if { [string tolower [HTTP::uri]] equals "/marketing/hello" } {   
          HTTP::redirect "http://www.website.org/Redirects/Marketing/CampaignStart.ASPX?CampaignId=2466"  
        }