Forum: NGINX Re: Request for a "no capture" rewrite directive enhancement

Df1412e1775840374894798d5ed9a7ea?d=identicon&s=25 Peter Mescalchin (Guest)
on 2014-05-28 06:55
(Received via mailing list)
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? :)


  Pete
0f7a1240e82f744c6c607fa7081b99f7?d=identicon&s=25 Igor Sysoev (Guest)
on 2014-05-28 12:02
(Received via mailing list)
On 28 May 2014, at 08:55, Peter Mescalchin <peter.mescalchin@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>.+)
{


--
Igor Sysoev
http://nginx.com
1266aa99d1601b47bbd3ec22affbb81c?d=identicon&s=25 B.R. (Guest)
on 2014-05-28 17:40
(Received via mailing list)
I think Igor is suggesting PERL named captures.

Although, it appears to me the correct syntax would rather be
(?<name>...),
as perlre docs
<http://perldoc.perl.org/perlre.html#Extended-Patte....
Then, just use you first syntax (omitting the 'set' directives).
---
*B. R.*
0f7a1240e82f744c6c607fa7081b99f7?d=identicon&s=25 Igor Sysoev (Guest)
on 2014-05-28 18:11
(Received via mailing list)
On 28 May 2014, at 19:39, B.R. <reallfqq-nginx@yahoo.fr> wrote:

> I think Igor is suggesting PERL named captures.
>
> Although, it appears to me the correct syntax would rather be (?<name>...), as
perlre docs state.
> Then, just use you first syntax (omitting the 'set' directives).


You a re right, I have mistaken.


--
Igor Sysoev
http://nginx.com
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.