Where is and Country
The goal is to add the rule to a VIP that will redirect to country specific folders on the same VIP. once a user hits the country specific folder they will get a cookie to identify the country choice so I do not want the rule to run very time but can't figure out how to get past the initial looping when a user does not have the country cookie.
The second part is the rule does not seem to work when I use country. Using the rule below I get get the redirect if I change $country to $state but no luck with Country
when CLIENT_ACCEPTED {
set country [class match -value [whereis [IP::client_addr]] equals CTS_COUNTRY]
set state [class match -value [whereis [IP::client_addr] abbrev] equals US_STATE]
log local0. "The country is [whereis [IP::client_addr] country] and the state is [whereis [IP::client_addr] abbrev]"
}
when HTTP_REQUEST {
if {[HTTP::cookie exists "SelectedCountryCode"]} {
log local0. "Cookie found [HTTP::cookie SelectedCountryCode]"
event HTTP_REQUEST disable }
elseif {($country ne "")}{
switch $country {
PA {HTTP::redirect http://www.testdomain.com/nsurvey}
US {HTTP::redirect http://www.testdomain.com/nsurvey}
CA {HTTP::redirect http://www.google.com}
AU {HTTP::redirect http://www.ctstestdomain.com/nsurvey}
GB {HTTP::redirect http://www.testdomain.com/nsurvey}
default {pool www.testdomain.com}
}
}
}
The logging does show Country and state but no redirect for country
: The country is US and the state is PA
: The country is GB and the state is 17
If I do away with the HTTP::cookie exists and use this I can get around the looping issue but the developers would like to use cookie
if { [class match [HTTP::uri] contains US_STATE]} {
event HTTP_REQUEST disable }
Any suggestions?