Forum Discussion
Robert_LaGrasse
Nimbostratus
Jul 14, 2006Appending address to uri
Stuck this in the wrong forum before...
Probably a very simple task for you iRule gurus out there, not so simple for my first iRule. Here's what I'm trying to accomplish... when the client request comes in to the login.aspx page on my host, I want to append an & or ? and his IP address to the uri. Here's what I've built, which is not working.
when HTTP_REQUEST {
set client [IP::client_addr]
set request [HTTP::uri]
if {$request contains "login.aspx" and $request contains "?"}
{HTTP::uri {$request + "&IPAddress=" + $client}}
elseif {$request contains "login.aspx"}
{HTTP::uri {$request + "?IPAddress=" + $client}}
}
Really nice pseudo code, but obviously not syntactically correct. This results in the F5 sending a GET / $request + "IPAddress=" + $client to my server, which it's obviously not finding. So, how do I fix it?
Thanks!
-B
- JRahm
Admin
Try this:when HTTP_REQUEST { if { [string tolower [HTTP::uri]] contains "login.aspx" } { if { [HTTP::uri] contains "?"} { HTTP::uri "[HTTP::uri]&IPAddress=[IP::client_addr]" } else { HTTP::uri "[HTTP::uri]?IPAddress=[IP::client_addr]" } } }
- Robert_LaGrasse
Nimbostratus
Thanks for the quick reply. I actually came up with this and successfully tested it a few minutes before I received your post:
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