Redirect a user based in country and querystring value

Igor Sysoev igor at sysoev.ru
Fri Apr 1 10:20:05 MSD 2011


On Thu, Mar 31, 2011 at 06:06:39PM -0400, nfn wrote:
> Hello,
> 
> I'm looking for a way to redirect users from some countries and with a
> querystring value to a specific page.
> 
> I tried this without success:
> 
>  location /register.php {
>   if (($geoip_country_code = (BR|PT)) and ($arg_action = "register")) {
>     rewrite ^(.*) /page/info/registo.html permanent;
>   }
> }
> 
> How can I accomplish this?

In 0.9.6 you can use

map "$geoip_country_code.$arg_action"  $registo {
     default      0;
     BR.register  1;
     PT.register  1;
}

   location = /register.php {
       if ($registo) {
           return  301  /page/info/registo.html;
       }
   }


-- 
Igor Sysoev
http://sysoev.ru/en/



More information about the nginx mailing list