Forum Discussion
Jacquesvd_10578
Nimbostratus
Nov 30, 2015Geolocation iRule,
Hi guys, maybe someone can assist me regarding this irule. Our client wants to do Geo Location using this irule.
Any suggestions from your side, its not working, I have tried a couple of different ...
Andy_McGrath
Cumulonimbus
Nov 30, 2015'string tolower' changes the country code to lowercase yet your switch statement is all in uppercase. Change to the following and give it a test:
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] contains "marksandspencerme.com" && [HTTP::path] eq "/" }{
Parse the client IP from the CDN header
set client_ip [HTTP::header value "Client-IP"]
if { $client_ip eq "" }{
The header was empty/did not exist, so use the actual client IP
set client_ip [IP::client_addr]
}
set country [string tolower [whereis $client_ip abbrev]]
switch $country {
"jo" -
"eg" -
"bh" -
"kw" -
"qa" -
"om" -
"lb" {
HTTP::redirect "http://www.marksandspencerme.com/-${country}"
}
default {
Redirect all others
HTTP::redirect "http://www.marksandspencerme.com/"
}
}
} else {
pool Pool_www.marksandspencerme.com_2.54_HTTP
}
}Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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