Forum Discussion

Gortguy_105156's avatar
Icon for Nimbostratus rankNimbostratus
Aug 31, 2011

Strange issue with "matches_regex" and case sensitivity

I'm a relative newbie to iRules, so please don't laugh if this is too simplistic.



I also have two environments, call them primary and test. I use essentially the same rule (copy/paste) for the two; they differ only by the pools they direct traffic to which is determined by the URI.



Here's the rule for the primary site:




if {[HTTP::uri] matches_regex "/MyURIString" } {


pool alt_pool


} else {


pool main_pool}





The rule for the test site:




if {[HTTP::uri] matches_regex "/MyURIString" } {


pool alttest_pool


} else {


pool maintest_pool}






The rule for the primary site works fine, regardless of the case of the URI.


ex: = OK = OK = OK



In the test site, however, the URL is case-sensitive:


ex: = OK = broken



Why would one rule require case-sensitivity while the other does not?


4 Replies

  • There is a good write-up that covers case-sensitivity in the URL here:



    As a general rule of thumb you should always do your compare with your data in a "known" state, so doing a string tolower will always help and make sure that the compare works.



    If you change this line to this, it should resolve your problem:


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



    What operating systems do each over your environments run on? I ask because for the most part IIS hosted Websites are case insensitive, but UNIX hosted applications are case sensitive.
  • They're all IIS on the back end, so I know that isn't the case.



    Thanks for the other information, though. I'll give that a try.
  • You should also consider using string functions instead of regexes if you can:



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



  • Hey Gort,



    Are the BIG-IP's that you are using running two different version of TMOS or are they at different patch levels?