Forum Discussion

falooda_281506's avatar
falooda_281506
Icon for Nimbostratus rankNimbostratus
Feb 22, 2017

iRULE difference between strong tolower

What is the difference between both iRule usuage, and when is best to use this:

 

elseif {[HTTP::uri] contains "/testweb/" {pool TESTweb}

 

elseif {[string tolower [HTTP::uri]] contains "/testweb/" {pool TESTweb}

 

2 Replies

  • I would prefer the second one. The tolower command will convert all characters in HTTP:uri to lowercase characters before it is compared to '/testweb/'. This will cause variations like '/tEstWeb/' to also match.

     

  • Hi falooda,

    the

    [string tolower [HTTP::uri]]
    syntax is the recommended approach, if a human is intended to type the URL into the address bar. In addition, this command is also recommended if you implement certain security controls (e.g. blacklists) and you want to make sure that a different /CaSE can not be used to bypass the policy...

    The user/attacker may enter:
    
    https://www.domain.de/shorturl
    https://www.domain.de/Shorturl
    https://www.domain.de/ShortUrl
    https://www.domain.de/SHORTURL
    

    Your first iRule snippet will trigger only on the first example. And your second iRule snippet will trigger in any of the above URL examples.

    Cheers, Kai