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

Df1412e1775840374894798d5ed9a7ea?d=identicon&s=25 Peter Mescalchin (Guest)
on 2014-05-28 01:53
(Received via mailing list)
Hello Nginx developers,

   speaking to Maxim Konovalov over Twitter, suggested this would be the
better place to get an answer to my suggestion.

Basically what I would like to see is the ability to use a rewrite
directive without the need to capture the current URI, which in turn
overwrites $1,$2,$x captures made within a location directive.

Best to explain via an example:

https://gist.github.com/magnetikonline/11364574


As you can see, this works (and works well) but the need to use "set" to
save copies of $1/$2 seems a little wasteful.

Digging through the documentation I can't seem to find a way of using
rewrite without blowing away/not capturing the current URI.


Thoughts?

   Pete
1266aa99d1601b47bbd3ec22affbb81c?d=identicon&s=25 B.R. (Guest)
on 2014-05-28 06:04
(Received via mailing list)
What about:

location ~ "^/[a-f0-9]{16}/(css|js)/(.+)" {

  expires 30d;
  return $scheme://$host/$1/$2? break;
}

?

You could add the 301 code for permanent redirect, see
http://nginx.org/r/return
---
*B. R.*


On Wed, May 28, 2014 at 1:52 AM, Peter Mescalchin <
0f7a1240e82f744c6c607fa7081b99f7?d=identicon&s=25 Igor Sysoev (Guest)
on 2014-05-28 06:44
(Received via mailing list)
On 28 May 2014, at 03:52, Peter Mescalchin <peter.mescalchin@gmail.com>
wrote:

>
> As you can see, this works (and works well) but the need to use "set" to save
copies of $1/$2 seems a little wasteful.
>
> Digging through the documentation I can't seem to find a way of using rewrite
without blowing away/not capturing the current URI.

location ~ "^/[a-f0-9]{16}/(css|js)/(.+)" {
  expires 30d;
  alias  /path/to/$1/$2;
}



--
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.