Geolocated redirect aFlex

Community Forum Forums Thunder and AX Series aFleX Geolocated redirect aFlex

This topic contains 0 replies, has 1 voice, and was last updated by avatar manuelm 7 years, 2 months ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #996
    avatar
    manuelm
    Member

    Hi team,

    Just a quick message to advertise about a specific aFlex adaptation I had to do.
    The actual iR**le is defined as following:

    when HTTP_REQUEST {
    set url [string tolower [HTTP::host]]
    if {$url ne “es.sites.xxx.com”} {
    switch [whereis [IP::client_addr] country] {

    ES { HTTP::redirect http://es.xxx.com }
    IT { HTTP::redirect http://it.xxx.com }
    BR { HTTP::redirect http://br.xxx.com }
    MX { HTTP::redirect http://mex.xxx.com }

    }
    }
    }

    We actually do not support the “whereis country” instruction, but it can easily be replaced by a check of the “Accept-Language” header, which will be even more precise in general, and also faster as you don’t need to wait for the “whereis” instruction to be executed.
    I had also to adapt the behavior of the “switch” instruction with the “-glob” option which allows to specify meta characters to make it easier in terms of programing and reading

    Here is the resulting aFlex

    when HTTP_REQUEST {
    set url [string tolower [HTTP::host]]
    if {$url ne “es.sites.xxx.com”} {
    switch -glob [HTTP::header “Accept-language”] {

    es-ES* { HTTP::redirect http://es.xxx.com }
    it-IT* { HTTP::redirect http://it.xxx.com }
    pt-BR* { HTTP::redirect http://br.xxx.com }
    es-MX* { HTTP::redirect http://mex.xxx.com }

    }
    }
    }

    Job done ;-)

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

Comments are closed.