Forum Discussion
dkinsler_23191
Nimbostratus
Jan 26, 2010Most efficient way to write this
My devs are asking me to Do many many redirects based on various mispellings our our URL's. I am worried about the extra processing of every request going through these lists of if/then statements. ...
hoolio
Cirrostratus
Jan 26, 2010The most efficient option might be to get a new IP address to resolve all the alternate spellings to and then use however complicated an iRule that you want.
Else, if you need to stick with one address, you can put the real hostname first in a switch statement and the rest afterward. That way you would only do one evaluation of the host header value for the majority of requests. I don't think evaluating the host header several times in a switch statement would add that much overhead anyhow, but it's always good to try to make things as efficient as possible.
when HTTP_REQUEST {
Check the requested host header (set to lowercase)
switch [string tolower [HTTP::host]] {
"realdomain.example.com" {
do nothing
}
"alternatespelling1.example.com" {
check the URI and/or redirect request
}
"alternatespelling2.example.com" {
check the URI and/or redirect request
}
default {
no match, take some default action?
}
}
}
Aaron
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
