Joe_Pipitone
Feb 04, 2015Nimbostratus
Removing www and https redirect
I've applied the following iRule to a VIP on port 80. It successfully strips the www if there is one, and then redirects to the VIP on port 443.
I also want to apply this iRule to the VIP on port 443, however that would result in a redirect loop unless I remove the else statement. I'm trying to consolidate and prevent having two different irules per set of VIPs. Is this possible?
when HTTP_REQUEST {
if {([string tolower [HTTP::host]] starts_with "www.")} {
HTTP::redirect "https://[string range [HTTP::host] 4 end][HTTP::uri]"
}
else {
HTTP::redirect https://[HTTP::host][HTTP::uri]
}
}