Forum Discussion

Srinivasan_G_31's avatar
Icon for Nimbostratus rankNimbostratus
Jun 06, 2012

GEO Based redirect




I need help on getting an iRule that performs redirect to a specific web page based on client browser's country of access/GEO information. If the user accesses the website from Asia i want to detect that information from the HTTP packet and redirect it to the APAC webpage on the web-server. Can you help me out here. Thanks a lot.






7 Replies

  • Hi Srinivasan,



    You can use the whereis and HTTP::redirect or HTTP::uri commands to do this:







    Do you want to rewrite the URI to hide the change from the client or redirect the request so the client sees the change? Do you want to change the hostname and/or URI?



  • Hi Aaron,



    Thanks for your post. I would probably want to hide the info from the client. Basically what i would like to do is match a country in an iRule and redirect it to a different webpage instead of redirecting it to a pool. I would also probably like to rewrite the URI if that is an option.






  • Hi Aaron,



    Also would like to know if GTM functionality is required to support the Whereis feature.



  • whereis is supported in 10.1 or higher for LTM. Here's an example of rewriting the URI based on the country code:



     Save the country code once per connection
    set cc [whereis [IP::client_addr] country]
    when HTTP_REQUEST {
     Check if the cc is not empty
    if {$cc ne ""}{
     Insert the country code in the requested URI
    HTTP::uri "/${cc}[HTTP::uri]"



  • Richard__Harlan's avatar
    Historic F5 Account
    I would use a switch statement for the HTTP_REQUEST. That way you will not have to create a country web page for each country out there. With the switch statement you will add all the country's you have webpages for then send the rest to the default page what ever it is.
  • Thanks Richard. I would like to have a sample iRule that accomplishes this as i am no iRule expert. Can you help here?
  • Hi Aaron,



    For using "whereis" do we need to install the geographic IP database into the system?