Forum Discussion
Craig_Hoss_1781
Nimbostratus
Jan 12, 2009Change 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.
2 Replies
- hoolio
Cirrostratus
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¶m2=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¶m2=value2
HTTP::uri (Click here) - /path/to/file.ext?param1=value1¶m2=value2
Aaron - Craig_Hoss_1781
Nimbostratus
I will give this a try.
Thank you very much for your response.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects