Gary_Bristol_19
Dec 15, 2015Nimbostratus
additional conditions on an irule
i have an iRule that does a check for a home page if it matches then send it to a specific pool. then i check a External Data Group list for redirection and pool selections or a default pool for none matches. the problem i have now is that not all fall through URL's are defined in the EDG list. but i also need the ou.edu/ match to re-direct to the www.ou.edu/. but ou.edu/something will also match that last entry and as such will not fall through.. here is my current iRule, thanks to the answeres here.
when HTTP_REQUEST {
Lookup the redirect or pool based upon match_string value
set goto [class match -value [string tolower [HTTP::host][HTTP::path]] starts_with www_ou_edu_redir_class]
if { [string tolower [HTTP::host][HTTP::path]] equals "www.ou.edu/" }{
pool www_ou_edu_cms_servers
} else {
switch [getfield $goto "," 1] {
"pool" { pool [getfield $goto "," 2] }
"redir" { HTTP::redirect [getfield $goto "," 2] }
default { pool ouwww_bostitch }
}
}
}
Here is what has been suggested as a replacement ..
when HTTP_REQUEST {
Lookup the redirect or pool based upon match_string value
if { ([string tolower [HTTP::host]] equals "ou.edu") and ([string tolower [HTTP::path]] equals "/") }{
HTTP::redirect "http://www.ou.edu/"
} else {
set host [string tolower "www.[HTTP::host][HTTP::path]"]
}
set host [string tolower "www.[HTTP::host][HTTP::path]"]
set goto [class match -value $host starts_with www_ou_edu_redir_class]
if { [string tolower [HTTP::host][HTTP::path]] equals "www.ou.edu/" }{
pool www_ou_edu_cms_servers
} else {
switch [getfield $goto "," 1] {
"pool" { pool [getfield $goto "," 2] }
"redir" { HTTP::redirect [getfield $goto "," 2] }
default { pool ouwww_bostitch }
}
}
}