Richard24_33536
Oct 03, 2017Nimbostratus
iRule Redirect based on Geolocation issues
I'm trying to create an iRule which redirects based on IP and Geolocation code for the 4 country codes listed. I currently have the following:
when HTTP_REQUEST {
if {[HTTP::path] eq "/" }
{
set client_ip [IP::client_addr]
set client_country [whereis $client_ip country]
if { $client_ip ne "" } {
switch [string toupper [whereis $client_ip country]] {
"AU" { HTTP::redirect "testsite.example.com.au" }
"SG" { HTTP::redirect "testsite.example.com.sg" }
"PH" { HTTP::redirect "testsite.example.com.ph" }
"MY" { HTTP::redirect "testsite.example.com.my" }
default { HTTP::redirect "testsite.example.com" }
}
}
}
}
I sourced this from here: http://itadminguide.com/big-ip-ltm-url-redirection-based-on-geolocation/
However, I'm getting "too many redirect errors" so I suspect it's getting stuck in a loop?
I'm new to this so any help will be much appreciated.
Thanks, Rich