Forum Discussion
Khoa_Le_50892
Feb 23, 2011Nimbostratus
iRules - multiple matches
Hi all, I'm new to iRules so need your help on fine tune of my iRule below. We are having serveral domain and subdomain and forward to same VS on F5. F5 will need to examine th...
hooleylist
Feb 23, 2011Cirrostratus
Hi Khoa,
I'd replace the if statements with a switch statement. This will save you from setting the host to lower case multiple times and lower the number of checks performed if a match is found:
when HTTP_REQUEST {
if {[HTTP::path] eq "/"}{
switch [string tolower [HTTP::host]] {
"www.xyzabc.com" -
"xyzabc.com" {
HTTP::redirect "https://www.xyzabc.com/xyz/web_portal/web/home/"
}
"www.hd.xyzabc.com" -
"hd.xyzabc.com" {
HTTP::redirect "https://www.xyzabc.com/xyz/web_portal/web/thuchanh_xyz/"
}
"www.kyso.xyzabc.com" -
"kyso.xyzabc.com" {
HTTP::redirect "https://kyso.xyzabc.com/digitalsign/web/"
}
"www.kyso.xyzabc.com" -
"kyso.xyzabc.com" {
HTTP::redirect "https://kyso.xyzabc.com/digitalsign/web/"
}
default {
Take some default action of the HTTP path is / and there isn't a match on the host?
}
}
}
}
Note that I left out the switch condition for this block of code as the host is already listed above:
if { [string tolower [HTTP::host]] eq "www.hd.xyzabc.com"} {
if { [string tolower [HTTP::uri]] eq "/" } {
HTTP::redirect "https://kyso.xyzabc.com/digitalsign/web/"
}
}
Aaron
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects