Forum Discussion
_pre_
Jul 06, 2011Nimbostratus
Simplifying route irules
Is there anyway to simplify the following rules
Route traffic to server1 if URL listed in class_goto_server1
when HTTP_REQUEST { ...
spark_86682
Jul 07, 2011Historic F5 Account
Hm. I think you actually could do a bit better. How about something like:
when HTTP_REQUEST {
set HTTPuri "[string tolower [HTTP::uri]]/"
URL starts_with check and Node select
if {[class match $HTTPuri starts_with class_toserver1_StartsWith]} {
pool server_1
}
}
Basically, always append a "/" character to the URI and then just do a "starts_with" search. If the URI is already "/staff-profile/" (or even "/staff-profile"), then that won't start with "/staff/", so it won't match that class entry. That way you're only doing one class lookup, and only have to maintain the one class.
If all of your class entries are only one directory level deep, then you can do even better than that:
when HTTP_REQUEST {
set HTTPtopdir "/[getfield [string tolower [HTTP::uri]] "/" 2]/"
top directory equals check and Node select
if {[class match $HTTPtopdir equals class_toserver1_equals]} {
pool server_1
}
}
That second example assumes the entries in class_toserver1_equals all end with slashes (meaning, "/staff/", and not "/staff").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