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
You suppose wrong, well almost...
Everything can be a variable so you can dynamically create a pool name based on inbound variables and then use the pool command (or with any other command)
Your rule doesn't work as-is but it would with a slight tweak. "$cust_id_pool" would be evaluated as the variable which doesn't exist. What you'll want to do is enclose the variable "cust_id" in braces like this:
when HTTP_REQUEST {
set cust_id [getfield [HTTP::uri] "/" 4]]
pool ${cust_id}_pool
} There are examples in the forums where customers are mapping portions of the hostnames and sections of the uri's into pool names, using portions of the hostnames to redirect to another uri on a common hostname for use in vanity domains,etc. You are really only limited by your imagination in what you can do.
I've been trying to highlight iRules that kind of stand out in my blog. You might want to take a peek when you get a chance:http://devcentral.f5.com/weblogs/joe/category/28.aspxClick here
Also, if you aren't already, click the "subscribe" checkbox at the top of each forum to get email notifications on each post. It's a good way to get some good ideas as well.
Oh, and hop on over to the TCL reference at Sourceforge for any language specific issues (such as regular expressions, binary scanning, string manipulation, etc):http://tmml.sourceforge.net/doc/tcl/Click here
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
