Forum Discussion
boczon_108037
Aug 16, 2011Nimbostratus
Where is and Country
Any one have any experience using whereis and redirecting based on country?. I have an irule I pieced together from examples found on devcentral and can get the rule to work for US States part way but...
Kevin_Davies_40
Aug 18, 2011Nacreous
when HTTP_REQUEST {
set debug 1
if {[HTTP::cookie exists "SelectedCountryCode"]} {
set country [HTTP::cookie "SelectedCountryCode"]
if {$debug} { log local0. "SelectedCountryCode = [HTTP::cookie SelectedCountryCode ]" }
} else {
set country [whereis [IP::client_addr] country]
}
if {$debug} { log local0. "Country is $country" }
switch $country {
PA { set redirect http://www.testdomain.com/nsurvey}
US { set redirect http://www.testdomain.com/nsurvey}
CA { set redirect http://www.google.com}
AU { set redirect http://www.ctstestdomain.com/nsurvey}
GB { set redirect http://www.testdomain.com/nsurvey}
default {
if {$debug} { log local0. "Unmatched country was $country" }
set redirect http://www.testdomain.com
}
}
if {$debug} { log local0. "Redirected to $redirect" }
HTTP::redirect $redirect
}
I didn't see any data classes listed so took them out for this code. Test and check the logging to validate the results. Then you can add the classes back in. Is the last pool command in your code meant to be a redirect? The pool name looks like a website name. You can turn off logging by setting debug 0 on the second line.
Kevin (Jarvil)
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