# NGINX location regex

**URL:** <https://www.ruby-forum.com/t/nginx-location-regex/209466>\
**Category:** NGINX\
**Created:** [July 14, 2011, 3:28pm UTC](https://www.ruby-forum.com/t/nginx-location-regex/209466 "2011-07-14T15:28:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [July 14, 2011, 3:28pm UTC](https://www.ruby-forum.com/t/nginx-location-regex/209466/1 "2011-07-14T15:28:25Z")

</div>

Hi,

I’m trying to configure nginx to match a location conf for URLs like the  
following:

[http://myserver.com/consume?id=123](http://myserver.com/consume?id=123)

but NOT the following:

[http://myserver.com/consumer/456](http://myserver.com/consumer/456)

I’ve tried several regex but something in nginx is working different in  
respect to an external regex matcher…

Can you help me , please?

Thanks,

Antonio

–

Antonio Pintus

Technologist  
ICT group  
CRS4, Center for Advanced Studies, Research and Development in Sardinia

e-mail: removed\_email\_address@domain.invalid  
Phone: +39 0709250268  
Skype: pintuxskype

CRS4 Home: [http://www.crs4.it](http://www.crs4.it)

---

<div class="post-metadata">

**Author:** ![Antonio\_Pintus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b9bd4f/32.png) [@Antonio\_Pintus](https://www.ruby-forum.com/u/Antonio_Pintus)\
**Post date:** [July 14, 2011, 3:42pm UTC](https://www.ruby-forum.com/t/nginx-location-regex/209466/2 "2011-07-14T15:42:40Z")

</div>

On 14 Jul 2011 14h27 WEST, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi,
> 
> I’m trying to configure nginx to match a location conf for URLs like  
> the following:
> 
> [http://myserver.com/consume?id=123](http://myserver.com/consume?id=123)
> 
> but NOT the following:
> 
> [http://myserver.com/consumer/456](http://myserver.com/consumer/456)

location = /consume {  
(…)  
}

Note that arguments are not ever matched on locations. The reason  
being that the order is arbitrary:

/consume?id=123&t=234 is the same as /consume?t=234&id=123

> I’ve tried several regex but something in nginx is working different  
> in respect to an external regex matcher…

> From what you wrote above I see no need to use a regex based location.

— appa

---

<div class="post-metadata">

**Author:** ![Antonio\_Pintus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b9bd4f/32.png) [@Antonio\_Pintus](https://www.ruby-forum.com/u/Antonio_Pintus)\
**Post date:** [July 14, 2011, 5:21pm UTC](https://www.ruby-forum.com/t/nginx-location-regex/209466/3 "2011-07-14T17:21:55Z")

</div>

Thanks Antonio,

it works.

Best,

Antonio

Il 14/07/11 15.41, Antnio P. P. Almeida ha scritto:

> > 
> 
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://nginx.org/mailman/listinfo/nginx)

–

Antonio Pintus

Technologist  
ICT group  
CRS4, Center for Advanced Studies, Research and Development in Sardinia

e-mail: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Phone: +39 0709250268  
Skype: pintuxskype

CRS4 Home: [http://www.crs4.it](http://www.crs4.it)
