# Help with location tag / reg ex

**URL:** <https://www.ruby-forum.com/t/help-with-location-tag-reg-ex/215301>\
**Category:** NGINX\
**Created:** [December 29, 2011, 7:52pm UTC](https://www.ruby-forum.com/t/help-with-location-tag-reg-ex/215301 "2011-12-29T19:52:06Z")\
**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:** [December 29, 2011, 7:52pm UTC](https://www.ruby-forum.com/t/help-with-location-tag-reg-ex/215301/1 "2011-12-29T19:52:06Z")

</div>

I’d like to match all of the media files in this sub directory (and  
subsequent directories) but its not working.

```
location ~* /_games/\.(jpg|jpeg|png|gif|swf|flv|mp3)$ {
  expires max;
}

```

My regular expression is off the mark…

Thanks

---

<div class="post-metadata">

**Author:** ![iberci](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/a3d4f5/32.png) [@iberci](https://www.ruby-forum.com/u/iberci)\
**Post date:** [December 29, 2011, 8:23pm UTC](https://www.ruby-forum.com/t/help-with-location-tag-reg-ex/215301/2 "2011-12-29T20:23:00Z")

</div>

On Thursday 29 December 2011 22:51:13 Ilan B. wrote:

> I’d like to match all of the media files in this sub directory (and  
> subsequent directories) but its not working.
> 
> ```
> location ~* /_games/\.(jpg|jpeg|png|gif|swf|flv|mp3)$ {
> expires max;
> }
> 
> ```
> 
> My regular expression is off the mark…

Your regexp matches URIs only like these:  
/\_games/.gif  
/\_games/.flv  
etc…

Probably, you want:

location ~\* /\_games/.+.(?:jpe?g|png|gif|swf|flv|mp3)$ {  
expires max;  
}

or, maybe:

location /\_games/ {  
location ~\* .(?:jpe?g|png|gif|swf|flv|mp3)$ {  
expires max;  
}  
}

Please, read:  
man pcrepattern  
man pcresyntax

wbr, Valentin V. Bartenev

---

<div class="post-metadata">

**Author:** ![iberci](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/a3d4f5/32.png) [@iberci](https://www.ruby-forum.com/u/iberci)\
**Post date:** [December 29, 2011, 8:26pm UTC](https://www.ruby-forum.com/t/help-with-location-tag-reg-ex/215301/3 "2011-12-29T20:26:42Z")

</div>

Thank you for your response, I was able to resolve, really appreciate  
it.  
My solution was along the same lines as yours.

On Thu, Dec 29, 2011 at 2:22 PM, Valentin V. Bartenev [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> man pcresyntax
> 
> wbr, Valentin V. Bartenev
> 
> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)

–

Ilan B.  
Chief Technology Officer

> **[Online Homeschool Curriculum from Time4Learning](https://www.time4learning.com/)**
>
> PreK-12 homeschooling is EASY with Time4Learning at your fingertips with award-winning online lessons, and parent-friendly planning and reporting tools.

6300 NE 1st Ave., Suite 203  
Ft. Lauderdale, FL 33334  
(954) 771-0914

[http://www.twitter.com/time4learning](http://www.twitter.com/time4learning)  
[http://www.facebook.com/Time4Learning](http://www.facebook.com/Time4Learning)

[Time4Learning.com](http://Time4Learning.com) - Online interactive curriculum for home use, PreK-8th  
Grade.  
[Time4Writing.com](http://Time4Writing.com) - Online writing tutorials for high, middle, and  
elementary school students.  
[Time4Learning.net](http://Time4Learning.net) - A forum to chat with parents online about kids,  
education, parenting and more.  
[spellingcity.com](http://spellingcity.com) - Online vocabulary and spelling activities for  
teachers,  
parents and students.
