Directive “try_files”

This directive should be used in server context, and a very common scenario is:

1
2
3
4
5
try_files $uri /friendly_404;

location /friendly_404 {
    return 404 "sorry, page not found";
}

So, each time a web request come in, the server will firstly try to find $uri, if it fails, then return 404. This could be used if some part of the application shut off by accident or under maintenance.

Leave a Reply

Your email address will not be published. Required fields are marked *