Forum Discussion
John_41578
Nimbostratus
Aug 31, 2009iRule that allows passing parameters
Hi,
Newbie here trying to figure things out. I have an iRule set as follows (condensed for brevity, actual paths removed for security):
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::uri]] {
"/foo" { pool content_pool }
"/foo/*" { pool content_pool }
default { pool pool_main_site }
}
}
What I want is for all requests for "/foo" and "/foo/*" to go to the content_pool while everything else goes to the main pool. I originally had "/foo*" but then "/foobar" was getting routed as well, which I didn't want. This rule works fine except for one problem: when parameters are passed to "/foo" the request goes to the default pool. For example...
This does not route to the content pool but should:
http://example.com/foo?i=1
These work as expected (route to content pool):
http://example.com/foo
http://example.com/foo/page
http://example.com/foo/page?i=1
Note that all pages may or may not have parameters passed, and these URIs should always route to the content pool regardless.
Also note that I have about 10 pages/paths that I need to do this with, not just foo. So also let me know if there's a cleaner, better, easier way to say "these 10 pages, plus everything under them, with or without parameters."
Thanks in advance,
John
3 Replies
- hoolio
Cirrostratus
Hi John,
You can check the path (URI minus the query string) using HTTP::path (Click here) instead of HTTP::uri in your switch statement. This will allow you to ignore the query string.
Also, for switch statements, if multiple cases use the same action, you can group them using the hyphen:when HTTP_REQUEST { switch -glob [string tolower [HTTP::path]] { "/foo"- "/foo/*" { pool content_pool } default { pool pool_main_site } } }
Aaron - John_41578
Nimbostratus
Thank you, Aaron. That worked perfectly! - hoolio
Cirrostratus
Good to hear.
Aaron
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
