Forum Discussion
iRule redirect to HTTPS - Logical Error
- Aug 14, 2014
Well, that elseif as it's currently written will never match because you're converting the host to lowercase and then attempting to match it against a string with upper case characters (websiteROOT). I realize this is a sanitized iRule, but I just wanted to raise this point in case that is your issue. Try this one:
when HTTP_REQUEST { if { [string tolower [HTTP::uri]] starts_with "/websiteA" } { pool pool_websiteA } elseif { [string tolower [HTTP::uri]] starts_with "/websiteB" } { pool pool_websiteB } elseif { [string tolower [HTTP::uri]] starts_with "/websiteC" } { pool pool_websiteC } elseif { [string tolower [HTTP::uri]] starts_with "/websiteD" } { pool pool_websiteD } elseif { [string tolower [HTTP::uri]] starts_with "/websiteE" } { pool pool_websiteE } else { HTTP::redirect "https://[HTTP::host][HTTP::uri]" } }
Well, that elseif as it's currently written will never match because you're converting the host to lowercase and then attempting to match it against a string with upper case characters (websiteROOT). I realize this is a sanitized iRule, but I just wanted to raise this point in case that is your issue. Try this one:
when HTTP_REQUEST {
if { [string tolower [HTTP::uri]] starts_with "/websiteA" } {
pool pool_websiteA
} elseif { [string tolower [HTTP::uri]] starts_with "/websiteB" } {
pool pool_websiteB
} elseif { [string tolower [HTTP::uri]] starts_with "/websiteC" } {
pool pool_websiteC
} elseif { [string tolower [HTTP::uri]] starts_with "/websiteD" } {
pool pool_websiteD
} elseif { [string tolower [HTTP::uri]] starts_with "/websiteE" } {
pool pool_websiteE
}
else {
HTTP::redirect "https://[HTTP::host][HTTP::uri]"
}
}
Recent Discussions
Related Content
* 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