bt_308832
Jun 20, 2018Nimbostratus
Detect Geo Location With iRule and Redirect
Hello,
I have this iRule:
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] contains "example.com" && [HTTP::path] eq "/" }{
set country [whereis [IP::client_addr] country]
switch $country {
"US" -
"UK" -
"CA" - { HTTP::redirect "https://example.com/${country}" }
}
}
}
The goal being to detect US, UK and CA users and then redirect them to a region specific page on the site. However with the rule enabled we just get back empty reply from F5. Turning it off or requesting example.com// (multiple trailing slashes) works. I'm thinking it has something to do with how the if statement is structure since adding additional slash characters corrects the problem but this is a bit out of my normal wheelhouse. Usually the F5 tasks I get delegated are updating SSL certificates and simple redirects.