Change Case on Append IP iRule

I have a working iRule that appends the IP address on a client request. However, it is case sensitive. The URL must have “login.aspx” in the URL exactly for this to work, but I would like to make it work with “Login.aspx”, “LOGIN.aspx”, etc. Does anyone know how to change the case of the incoming URL ?

when HTTP_REQUEST {

set client [IP::client_addr]

set request [HTTP::uri]

if {$request contains “login.aspx” and $request contains “?”}

{HTTP::uri “[HTTP::uri]&IPAddress=[IP::client_addr]”}

elseif {$request contains “login.aspx”}

{HTTP::uri “[HTTP::uri]?IPAddress=[IP::client_addr]”}

}

Thanks.

You can use ‘string tolower “original_string”’ to set a string to lower case. You can eliminate some of the variables as well:

when HTTP_REQUEST {  
    
      Check if the path, set to lower case, ends with login.aspx  
     if {[string tolower [HTTP::path]] ends_with "login.aspx"}{   
    
         Check if there is a query string  
        if {[string length [HTTP::query]]}{  
    
            Append the IPAddress parameter with the client IP to the existing query string  
           HTTP::uri "[HTTP::uri]&IPAddress=[IP::client_addr]"  
    
        } else {  
    
            Append the IPAddress parameter with the client IP to the path  
           HTTP::uri "[HTTP::path]?IPAddress=[IP::client_addr]"  
        }  
     }  
  }

For an example URL:

http://www.example.com:80/path/to/file.ext?param1=value1&param2=value2

These commands return the following values:

HTTP::host (Click here) - www.example.com:80

HTTP::path (Click here) - /path/to/file.ext

HTTP::query (Click here) - param1=value1&param2=value2

HTTP::uri (Click here) - /path/to/file.ext?param1=value1&param2=value2

Aaron

I will give this a try.

Thank you very much for your response.