Question about rewrite

Denis S. Filimonov den.lists at gmail.com
Sun Apr 6 21:13:21 MSD 2008


On Sunday 06 April 2008 12:52:54 bianbian wrote:
> Hi.
> So "last" means "finish this time and repeat matching from the start", and
> "break" means "finish rewrite"?
Yes, that's correct.
You use "last" when you want the updated url to go through location matching 
process again, and "break" when you don't.

> But I confused which situation we need "break", if I just finish rewrite
> rule--- I maybe don't need rewrite.
> In my case, I need to redirect a "internal" location, so I must use "last"
> here?
> ( /openpath/file.ext  ====>  @realpath/cache_file.ext )
>
>   location ~^ /openpath/ {
>        rewrite   /openpath/(\w+)\.(\w+)       @realpath/cache_$1.$2
> last;
>   }
>
>   location ~^ @realpath/ {
>        alias    /realpath;
>        internal;
>   }
Yes, in this situation you need a "last". However, I don't think it'll work 
with @ in the location, I think those are more like identifiers of locations, 
rather than actual locations to which you can append stuff. You can 
use /realpath/, as long as it's "internal" nobody will get there directly. I 
could be wrong, though.

-- 
Denis.





More information about the nginx mailing list