URL rewriting: last versus break

Hi,

I don’t understand the difference between “last” and “break”. Can
someone explain me how it works or point me to some more detailed
info?

Best regards,

On Thursday 03 July 2008, Thomas wrote:

Hi,

I don’t understand the difference between “last” and “break”. Can
someone explain me how it works or point me to some more detailed
info?

wiki didn’t help?

location / {
rewrite ^/foo$ /foo.php last;
rewrite ^/bar$ /bar.php break;
}

location ~ .php$ {
proxy_pass …;
}

request /foo will return proxy_pass response (“location ~ .php” will be
used)
request /bar will return source code of foo.php (“location /” will be
used)

Okay, so “break”, means “if regexp matches the request, then rewrite
the request and then stop right here and serve the request as being a
static file”.

“last” means “if regexp matches the request then rewrite the request,
then do not move on to any subsequent rewriting rule, but now try to
match the request with a location in the config file”

Am I right?

On Thu, Jul 03, 2008 at 10:22:43PM +0200, Thomas wrote:

Okay, so “break”, means “if regexp matches the request, then rewrite
the request and then stop right here and serve the request as being a
static file”.

… and then stop right here (in this location) and serve the request
by the location’s handler (static/proxy/fastcgi/etc)

“last” means “if regexp matches the request then rewrite the request,
then do not move on to any subsequent rewriting rule, but now try to
match the request with a location in the config file”

Yes.

On 7/3/08, Roxis [email protected] wrote:

request /foo will return proxy_pass response (“location ~ .php” will be used)
request /bar will return source code of foo.php (“location /” will be used)

doesn’t this mean my current approach is overkill?

    server {
            listen 80;
            server_name foo.com;
            index index.php index.html;
            root /home/foo/web/foo.com/;
            include /etc/nginx/defaults.conf;
            location ~ \.php {
                    fastcgi_pass 127.0.0.1:11002;
                    fastcgi_index index.php;
            }
            location /admin {
                    auth_basic "private";
                    auth_basic_user_file 

/home/foo/web/foo.com/.htpasswd;
location ~ .php {
fastcgi_pass 127.0.0.1:11002;
fastcgi_index index.php;
}
}
}

according to what it sounds like above, i could do this right the
right keywords (break vs. last) in the right spots.

i need php to execute under the location /admin directory… i posted
this question a couple weeks ago, but it sounds like it might be
doable using the strategy above. however, which goes where?

do i have to use some sort of rewrite to trigger it all?

Okay, so “break”, means “if regexp matches the request, then rewrite
the request and then stop right here and serve the request as being a
static file”.

… and then stop right here (in this location) and serve the request
by the location’s handler (static/proxy/fastcgi/etc)

So rewrite rules with break must be declared inside a location,
whereas rewrite rules with last have to be declared outside locations?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs