Currently I have an iRule in place that does uses switch to do a web site redirect and a http to https redirect on a http VIP, see below.
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::host]] {
"abc.com" -
"www.abc.com" {
HTTP::redirect http://abc.123.com
}
"def.com" -
"www.def.com" {
HTTP::redirect https://www.def.com[HTTP::uri]
}
default {
reject
}
}
}
Now, I like to also implement a similar redirect on the https VIP. Basically, I need to redirect https://def.com to https://www.def.com. Could I use something similar to the above?
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::host]] {
"def.com" -
"www.def.com" {
HTTP::redirect https://www.def.com[HTTP::uri]
}
default {
reject
}
}
}
Or, should I use the below, which I found on another post?
when HTTP_REQUEST {
if { !([HTTP::host] starts_with "www.") &&
([HTTP::host] contains "hostname.net") ) {
HTTP::redirect "https://www.[HTTP::host][HTTP::uri]"
}
}
Any suggestions would be helpful? The main thing is that the iRules would not conflict with one another, which I don’t think would be the case since they are for different VIPs.