Forum Discussion
Richard_Kim_270
Nimbostratus
Jan 11, 2007iRule for starts with "reports/" data group?
I'm looking for an iRule that will redirect the request to a pool if the URL contains a "/reports/* in the URL path. Currently I am using:
when HTTP_REQUEST {
if { [matchclass [HTTP::uri] contains $::Report_Strings] } {
pool RP_pool_1
}
}
Report_strings is the data group and has several specific paths that I am adding manually every time we discovery a new report path. There has to be an easier way! Also, I would like the request to ignore Uppercase/lower case so it is not case sensitive. Thanks.
- JRahm
Admin
Try this:when HTTP_REQUEST { if { [matchclass [string tolower [HTTP::uri]] contains $::Report_Strings] } { pool RP_pool_1 } }
- Richard_Kim_270
Nimbostratus
- JRahm
Admin
yes & yes. Conversely, you can use string toupper if you want to go that route. - Yes, the "strings tolower" built-in TCL command will convert the string to lower case. So, if you "string tolower" the HTTP::uri you will want all your strings in your Report_Strings data group to be lower case.
when HTTP_REQUEST { if { [string tolower [HTTP::uri]] starts_with "/reports/" } { pool RP_pool_1 } }
when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/reports/*" { pool RP_pool_1 } } }
- That should work for you. The only problem with the contains operator is that it acts like "*string*" so for report the following urls would workhttp://host/report/foo
when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/admin/*" - "/report/*" - "/reports/*" { pool RP_pool_1 } } }
when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "*/admin/*" - "*/report/*" - "*/reports/*" { pool RP_pool_1 } } }
when CLIENT_ACCEPTED { set default_pool [LB::server pool] } when HTTP_REQUEST { if { [matchclass [string tolower [HTTP::uri]] starts_with $::Report_strings_matchclass] } { pool RP_pool_1 } else { pool $default_pool } }
- Richard_Kim_270
Nimbostratus
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