# Location based on querystring

**URL:** <https://www.ruby-forum.com/t/location-based-on-querystring/183538>\
**Category:** NGINX\
**Created:** [February 16, 2010, 9:31am UTC](https://www.ruby-forum.com/t/location-based-on-querystring/183538 "2010-02-16T09:31:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![budala10](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/58f4c7/32.png) [@budala10](https://www.ruby-forum.com/u/budala10)\
**Post date:** [February 16, 2010, 9:31am UTC](https://www.ruby-forum.com/t/location-based-on-querystring/183538/1 "2010-02-16T09:31:51Z")

</div>

Hi.

Let’s say ia have 2 different url’s to a backend.

On is [http://domain.com/a.b.c.d](http://domain.com/a.b.c.d), this i just want to proxy to a backend.

But if the reguest is like, [http://domain.com/a.b.c.d?id=1222](http://domain.com/a.b.c.d?id=1222) then i  
would like to proxy it somewhere else.

How can this be done, eq i just want to proxy urls with ?id=\* in it to  
antoher backend.

Please help if can.

/Budala

Posted at Nginx Forum:

> **[location based on querystring](https://forum.nginx.org/read.php?2,54953,54953#msg-54953)**
>
> Hi. Let's say ia have 2 different url's to a backend. On is http://domain.com/a.b.c.d, this i just want to proxy to a backend. But if the reguest is like, http://domain.com/a.b.c.d?id=1222 then i would like to proxy it somewhere else.

---

<div class="post-metadata">

**Author:** ![budala10](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/58f4c7/32.png) [@budala10](https://www.ruby-forum.com/u/budala10)\
**Post date:** [February 16, 2010, 11:03am UTC](https://www.ruby-forum.com/t/location-based-on-querystring/183538/2 "2010-02-16T11:03:45Z")

</div>

Hello!

On Tue, Feb 16, 2010 at 03:31:10AM -0500, budala10 wrote:

> Let’s say ia have 2 different url’s to a backend.
> 
> On is [http://domain.com/a.b.c.d](http://domain.com/a.b.c.d), this i just want to proxy to a  
> backend.
> 
> But if the reguest is like, [http://domain.com/a.b.c.d?id=1222](http://domain.com/a.b.c.d?id=1222)  
> then i would like to proxy it somewhere else.

```
location = /a.b.c.d {
    if ($args = "id=1222") {
        rewrite ^ /a.b.c.d.id1222 last;
    }
    proxy_pass ...;
}

location = /a.b.c.d.id1222 {
    proxy_pass ...;
}

```

Maxim D.

---

<div class="post-metadata">

**Author:** ![budala10](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/58f4c7/32.png) [@budala10](https://www.ruby-forum.com/u/budala10)\
**Post date:** [February 16, 2010, 2:17pm UTC](https://www.ruby-forum.com/t/location-based-on-querystring/183538/3 "2010-02-16T14:17:30Z")

</div>

good idea… thanks

Then another question, my backend application sucks so i need to take  
some load off it with nginx.

lest say, [http://domain.com/a.b.c.d?id=32323](http://domain.com/a.b.c.d?id=32323) is working as you  
specified.

what do i do if [http://domain.com/a.b.c.d/32323](http://domain.com/a.b.c.d/32323) sould be redirected to  
[http://domain.com/a.b.c.d?id=32323](http://domain.com/a.b.c.d?id=32323) ?

then everything should be perfect…

Posted at Nginx Forum:

> **[Re: location based on querystring](https://forum.nginx.org/read.php?2,54953,55030#msg-55030)**
>
> Hi. Let's say ia have 2 different url's to a backend. On is http://domain.com/a.b.c.d, this i just want to proxy to a backend. But if the reguest is like, http://domain.com/a.b.c.d?id=1222 then i would like to proxy it somewhere else.
