iRule to switch hostnames to www.
Hi all, this is my first post and I'm not an F5 legend so please bare with me if this is obvious.
Our customer facing websites are published with a full www URL - i.e. www.mycompany.com. This DNS record is a CNAME which points to an A record of live.mydomain.com.
[The idea is that if the web servers behind that VS need to be taken down, we can very quickly change that CNAME to instead point to backup.mydomain.com in another cluster (but behind the same LB). CNAME changes propagate a lot quicker than A record changes so this is effectively a manual GTM.]
Anyway, our problem is that because live.mydomain.com and backup.mydomain.com are public facing, people who know these hostnames can access the site effectively on the wrong URL - this is bad for our internet stats as sites like google can see our content on 2-3 urls and therefore mark us down in search.
I've created an iRule to 301-redirect either live. or backup. to www.mydomain.com but would like to ask if this logic is correct, or indeed whether it could be more efficient for my needs, the last thing I want is to get stuck in a loop!:
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::host]] {
"live.mydomain.com" {
HTTP::respond 301 Location "http://www.mydomain.com[HTTP::uri]"
}
"backup.mydomiain.com" {
HTTP::respond 301 Location "http://www.mydomain.com[HTTP::uri]"
}
}
}
Here's hoping.
Cheers, Steve.