Nicolas_Bellen1
Jun 03, 2011Nimbostratus
REGEX Alternatives
I've been trying to figure out how i'd structure a particular portion of my iRule to look for values contained in a string, instead of a regular expression but i'm having some difficulty:
The first conditional is straightforward and has a static value. However the second conditional would be DRC followed by 5 numbers. Is there any way to structure this so it uses a more efficient method? Here's what i have:
if {([string tolower [HTTP::uri]] contains "mastermenu") ||
([HTTP::uri] matches_regex {DRC(\d)+})}
The other issue i'm running into is how i would replace the host portion of the redirect location, yet leave the URI intact. I tried the following, but couldn't quite figure out how to structure the first parameter of the string map to match on the host portion without using a regular expression. I borrowed this portion (from http://devcentral.f5.com/wiki/default.aspx/iRules/RewriteHTTPRedirectHostname.html), but couldn't quite piece it together.
if { [HTTP::is_redirect] } {
HTTP::header replace Location [string map -nocase {"abc.example.com" "def.example.com"} [HTTP::header value Location]]}
Any help would be appreciated!
Nick