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 ;-)