# Redirect a user based in country and querystring value

**URL:** <https://www.ruby-forum.com/t/redirect-a-user-based-in-country-and-querystring-value/205205>\
**Category:** NGINX\
**Created:** [April 1, 2011, 12:06am UTC](https://www.ruby-forum.com/t/redirect-a-user-based-in-country-and-querystring-value/205205 "2011-04-01T00:06:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [April 1, 2011, 12:06am UTC](https://www.ruby-forum.com/t/redirect-a-user-based-in-country-and-querystring-value/205205/1 "2011-04-01T00:06:58Z")

</div>

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?

Thanks

Posted at Nginx Forum:

> **[Redirect a user based in country and querystring value](https://forum.nginx.org/read.php?2,187241,187241#msg-187241)**
>
> 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&quot

---

<div class="post-metadata">

**Author:** ![nfn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b19c9b/32.png) [@nfn](https://www.ruby-forum.com/u/nfn)\
**Post date:** [April 1, 2011, 12:10am UTC](https://www.ruby-forum.com/t/redirect-a-user-based-in-country-and-querystring-value/205205/2 "2011-04-01T00:10:41Z")

</div>

I’m using 0.8.54-4ppa17~lucid full from

> **[NGINX Stable : “Nginx” team](https://launchpad.net/~nginx/+archive/ubuntu/stable)**
>
> This PPA contains the latest Stable Release version of the nginx web server software.
> 
> \*\*Only Non-End-of-Life Ubuntu Releases are supported in this PPA\*\*
> 
> \*\*Development releases of Ubuntu are not officially supported by this PPA, and uploads for...

Posted at Nginx Forum:

> **[Re: Redirect a user based in country and querystring value](https://forum.nginx.org/read.php?2,187241,187242#msg-187242)**
>
> 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&quot

---

<div class="post-metadata">

**Author:** ![nfn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b19c9b/32.png) [@nfn](https://www.ruby-forum.com/u/nfn)\
**Post date:** [April 1, 2011, 8:20am UTC](https://www.ruby-forum.com/t/redirect-a-user-based-in-country-and-querystring-value/205205/3 "2011-04-01T08:20:17Z")

</div>

On Thu, Mar 31, 2011 at 06:06:39PM -0400, nfn wrote:

> }  
> }
> 
> 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 S.

> **[Igor Sysoev](http://sysoev.ru/en/)**
