# Re: Request for a "no capture" rewrite directive enhancement

**URL:** <https://www.ruby-forum.com/t/re-request-for-a-no-capture-rewrite-directive-enhancement/230066>\
**Category:** NGINX\
**Created:** [May 29, 2014, 4:10am UTC](https://www.ruby-forum.com/t/re-request-for-a-no-capture-rewrite-directive-enhancement/230066 "2014-05-29T04:10:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jason\_sam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7993a0/32.png) [@jason\_sam](https://www.ruby-forum.com/u/jason_sam)\
**Post date:** [May 29, 2014, 4:10am UTC](https://www.ruby-forum.com/t/re-request-for-a-no-capture-rewrite-directive-enhancement/230066/1 "2014-05-29T04:10:13Z")

</div>

## Fantastic Igor - I didn’t know that you could do named captures in Nginx

good to know.

That solves it rather nicely.

And thanks B.R. - yep, that syntax is part of PCRE.

Pete

> I think Igor is suggesting PERL named captures.
> 
> ## Although, it appears to me the correct syntax would rather be (?…), as perlre docs \<[perlre - Perl regular expressions - Perldoc Browser](http://perldoc.perl.org/perlre.html#Extended-Patterns) state. Then, just use you first syntax (omitting the ‘set’ directives).
> 
> _B. R._
> 
> On Wed, May 28, 2014 at 12:02 PM, Igor S. wrote:
> 
> > On 28 May 2014, at 08:55, Peter M. \<peter.mescalchin at  
> > [gmail.com](http://gmail.com)\>  
> > wrote:
> > 
> > Thanks Igor,
> > 
> > I had explored that method already, sadly (as you know) “alias” is  
> > given as an absolute path meaning I can’t use this block of config  
> > within  
> > multiple virtual hosts which I include; - would have to re-write this  
> > same  
> > block of config for each Virtual host modifying the alias path prefix.
> > 
> > And since alias man page explicitly states that $document\_root can’t be  
> > used it’s not possible to complete this config in a reusable way. (e.g.  
> > alias $document\_root/path/to/$1/$2; would be perfect).
> > 
> > Alas, I think what I have (storing the captures in temp vars) is the  
> > only  
> > real solution thus far.
> > 
> > Unless the penny hasn’t dropped in my head? 🙂
> > 
> > Then you can set these variable directly in regex:  
> > location ~  
> > "^/[a-f0-9]{16}/(\<?resource\_type\>css|js)/(\<?resource\_path\>.+)” {

---

<div class="post-metadata">

**Author:** ![dracos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ea666f/32.png) [@dracos](https://www.ruby-forum.com/u/dracos)\
**Post date:** [May 29, 2014, 4:47am UTC](https://www.ruby-forum.com/t/re-request-for-a-no-capture-rewrite-directive-enhancement/230066/2 "2014-05-29T04:47:42Z")

</div>

Yup the location directive uses the PCRE library to interpret regex.  
Its docs doesn’t mention that the regex are PCRE, but the hint is given  
away on the build from sources  
[http://nginx.org/en/docs/configure.html](http://nginx.org/en/docs/configure.html)page.

It reminds me that not so long ago I mixed up named captures and  
subpatterns syntax trying to play with PCRE in location… but that is  
another story ;o)

## Glad I could help!

_B. R._

On Thu, May 29, 2014 at 4:09 AM, Peter M. \<
