Since you are just looking for the first characters in the string, have you tried the "starts_with" operator? substr actually allocates another string which has some overhead.
if (tolower(http_uri) starts_with "/ab/") {
use pool WebPool1
} else if (tolower(http_uri) starts_with "/cdefg/") {
use pool WebPool1
} else {
use pool WebPool2
}
Or, you could combine the first two checks into the first if
if ( (tolower(http_uri) starts_with "/ab") or
(tolower(http_uri) starts_with "/cdefg/") ) {
use pool WebPool1
} else {
use pool WebPool2
}
Those should both perform roughly the same though.
I'm not sure you could optimize this rule more that this.
-Joe