dundovic_25174
Oct 25, 2011Nimbostratus
'if' gets ignored
I wrote following iRule in attempt to redirect two specific requests to desired pages and would like to have any other request with path beginning with '/1' to get redirected to homepage:
---
when HTTP_REQUEST {
set uri [string tolower [HTTP::uri]]
set host [string tolower [HTTP::host]]
set link "$host$uri"
switch -exact $link {
"www.domain.com/1/2/something" {HTTP::redirect "http://www.domain.com/something.html"}
"www.domain.com/1/2/something2" {HTTP::redirect "http://www.domain.com/something2.html"}
if { [HTTP::host] equals "www.domain.com" and [HTTP::path] starts_with "/1" } then {
HTTP::redirect "http://www.domain.com"
}
}
}
---
The explicit redirects work fine, but the 'if' statement that checks for '/1' in path start gets totally ignored. Could somebody clarify why?
Regards,
D.