gbunting
Mar 19, 2009Nimbostratus
How to clean up multiple if/else redirects?
I have a current iRule that works. It will redirect from www.domainname.com.au to www.domainname.com/au for multiple international domains. The problem is I currently have 7 if/else statements for 7 international domains and I have just found out that I will need to add approximately 20 more domains. My question is, is there a better way to create this rule that will be more easily manageable given the number of if/els statements I will need to add? I tried looking into using data groups, but I am not sure how to go about parsing them.
Here is my current iRule:
when HTTP_REQUEST {
if { [HTTP::host] starts_with "www.osisoft.com"} {
pool www.osisoft.com
}
elseif { [HTTP::host] starts_with "www.osisoft.com.br"} {
HTTP::redirect "http://www.osisoft.com/Brazil"
}
elseif { [HTTP::host] starts_with "www.osisoft.com.au"} {
HTTP::redirect "http://www.osisoft.com/Australia"
}
elseif { [HTTP::host] starts_with "www.osisoft.com.mx"} {
HTTP::redirect "http://www.osisoft.com/Mexico"
}
elseif { [HTTP::host] starts_with "www.osisoft.com.ca"} {
HTTP::redirect "http://www.osisoft.com/Canada"
}
elseif { [HTTP::host] starts_with "www.osisoft.cz"} {
HTTP::redirect "http://www.osisoft.com/Chech"
}
elseif { ([HTTP::host] starts_with "www.osisoft.co.jp") ||
([HTTP::host] starts_with "www.osisoft.jp") } {
HTTP::redirect "http://www.osisoft.com/Japan"
}
else { pool www.osisoft.com
}
}
Thanks
Glen