Break flag in rewrite directive

Hi,
I wanted to ask about break flag in rewrite directive as i understand
Nginx
does not initiate a new request for the modified URI but i cant
understand
how this will be useful?

Posted at Nginx Forum:

Hello!

On Sun, Jul 27, 2014 at 07:37:01AM -0400, husseingalal wrote:

Hi,
I wanted to ask about break flag in rewrite directive as i understand Nginx
does not initiate a new request for the modified URI but i cant understand
how this will be useful?

There is an example in docs, Alphabetical index of directives

location /download/ {
    rewrite ^(/download/.*)/media/(.*)\..*$ $1/mp3/$2.mp3 break;
    rewrite ^(/download/.*)/audio/(.*)\..*$ $1/mp3/$2.ra  break;
    return  403;
}

The “break” flag is used here to change an URI, but keep
processing in the already matched location. For example, a
request to “/download/foo/media/bar.mp3” will be mapped to the
“/root/download/foo/mp3/bar.mp3” file, where “/root” is the
document root in the “/download/” location.


Maxim D.
http://nginx.org/