Forum Discussion
Martin_Kaiser_1
Nimbostratus
Oct 20, 2005using getfield to split up URIs
Hi there,
can anyone of you show me the correct syntax for using the function getfield in an iRule?
What I want to do is split up an URI like "/webstart/portal/customer_id/some/more/fie...
Oct 20, 2005
Martin,
Here is the documentation for getfield (from the BIG-IP Users Manual)getfield
The getfield command splits a string on a character, and returns the string corresponding to the specific field.
The syntax of the getfield command is:
getfield
So, for your example, you'll want to use the HTTP::uri for the "string" value, a slash for the "split" value and value of 4 for the "field" (the first field will be empty since there is nothing before the split char).
when HTTP_REQUEST {
set cust_id [getfield [HTTP::uri] "/" 4]]
if { $cust_id equals "company1" } {
pool company1_pool
} elseif { $cust_id equals "company2" } {
pool company2_pool
}
}If your uri's can be mixed case, you might want to throw in a "string tolower" in there to convert the HTTP::uri to lowercase before the comparison.
when HTTP_REQUEST {
set cust_id [string tolower [getfield [HTTP::uri] "/" 4]]]
if { $cust_id equals "company1" } {
pool company1_pool
} elseif { $cust_id equals "company2" } {
pool company2_pool
}
}Good luck!
-Joe
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
