Forum Discussion

KT_271103's avatar
KT_271103
Icon for Nimbostratus rankNimbostratus
Aug 31, 2017

Need irule to match case sensitive characters

Need Irule for matching Words of lower and caps. for instance, the name "abcd" is using in URI. Whoever hits URI with "abcd" either lower or upper case it should block webpage. for other URI the page should load.

 

Please let me know how to do that?

 

  • Hi KT,

    to ignore the case while comparing URIs you have to add a [string tolower $input] or [string toupper $input] to format the URI value into either lowercase or uppercase. Then compare the URI with either lowercase or uppercase formated values.

    when HTTP_REQUEST {
        if { [string tolower [HTTP::uri]] contains "abcd" } then {
            HTTP::respond 403 content "Access denied..." "Content-Type" "text/html"
        }
    }
    

    Note: In the example above the

    [string tolower [HTTP::uri]]
    syntax won't change the HTTP-request as is. The syntax will only use a lower case formating of your URI while comparing the URI value...

    Cheers, Kai