nginx-configuration try_files detailed explanation

try_files is an instruction included in the http_core core module in nginx . It can mainly replace some rewrite instructions and improve parsing efficiency.

1. Grammar:

 Syntax rules for try_files:

Format 1: try_files file  ...  uri

Format 2: try_files  file  ... = code ;

2.Meaning

  • Key point 1: Search for existing files in the specified file order, and use the first found file for request processing
  • Key point 2: The search path is based on the given root or alias as the root path.
  • Key point 3: If none of the given files are matched, re-request the uri given by the last parameter, which is the new location match.
  • Key point 4: If it is format 2, if the last parameter is = 404, and if none of the given files are matched, the response code of 404 will be returned.
     

It can be understood as the path to obtain resources first

Guess you like

Origin blog.csdn.net/qq_44691484/article/details/126354602