Pass Country Code in URL using iRule and Geolocation

Here is a simple example that explains how to pass Country Code as variable in URL using iRule. I assume that you have already configured your F5 appliance with GeoLocation database, otherwise refer my article BIG-IP LTM url redirection based on Geolocation and set it up.

In this example, when someone browse, HTTP::path returns “/” and passes $client_country variable value in the URL – https://[HTTP::host]/member/$client_country, passes $client_country

set client_country [whereis $client_ip country]
if {[active_members appserver_pool]<1}
{ HTTP::redirect “” }
elseif { [HTTP::path] eq “/” }
{ HTTP::redirect “https://[HTTP::host]/member/$client_country” }
{ pool appserver_pool}