Chris_DiPietro_
Mar 08, 2012Nimbostratus
redirecting urls to add www to the host if it does not exists
I have two VSs one responds to port 80 but redirects to https and one responds to HTTPS, but I want to make sure anyone trying to get to sample.com gets redirected to www.sample.com so the SSL cert matches correctly
I wrote the following iRules based on what I have found in other posts and I just want to make sure these are correct
For the port 80 VS
when HTTP_REQUEST {
if
{[string tolower [HTTP::host]]
starts_with "www"} {
HTTP::respond 301 Location ""
} else {
HTTP::respond 301 Location "":" 1][HTTP::uri]"
}
}
for the port 443 VS
when HTTP_REQUEST {
if { not ([string tolower [HTTP::host]]
starts_with "www") } {
HTTP::respond 301 Location "":" 1][HTTP::uri]"
}
}
If this is wrong or there is a cleaner/better way to do this please let me know
Thanks