Forum Discussion
Born_7758
Jul 18, 2011Nimbostratus
Modify URI among other things
Hello Everyone, Here's what I am trying to do: I have a datagroup called payment_resp_1 When I receive a request I want to match it to the URIs in the datagroup, ...
Colin_Walker_12
Jul 19, 2011Historic F5 Account
Well, after looking again it looks like the rule needs just a little updating. Try this:
when HTTP_REQUEST {
set uri [findclass [HTTP::path] uri_class " "]
if {$line ne ""}{
HTTP::uri $uri
node 10.48.52.58 8080
}
}
With a class where each line looks like:
"original_uri new_uri"
Okay, now for the explanation. What this is doing is looking through the class to find the current HTTP::path (the portion of the URI before the query string). Once it finds the current path in the data group, it will retrieve whatever comes after the separator (the " " in this case) and return that as the value of the findclass.
So, that means that in the above case, assuming [HTTP::path] were "original_uri", the findclass command would return "new_uri". Then the HTTP::uri $uri command sets the uri to be equal to $uri, which we just established was "new_uri".
Basically, you're creating key->value pairs within your data group. The key is whatever is before the space in each string. This should be the original URI that you want to search for. The value comes after the space, and that is whatever you want the original URI to be re-written to. The iRule then automagically goes through and does just that, then sends the connection on to the specified node.
Make sense?
Colin
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