try_files Try to read the file accessed by the user to the website directory, and return it directly if the first variable exists; There is no continued reading of the second variable, and if it exists, it returns directly; There is no jump directly to the third parameter.
try_files The configuration is as follows:
When the user requestshttp://localhost/example, the $uri here is /example. try_files will try to find this file on your hard drive. If there is a file named /$root/example (where $root is the installation directory of the project code), send the contents of this file directly to the user. Obviously, there is no file called example in the directory. Then look at $uri/, add a /, that is, see if there is a directory named /$root/example/. If it can't find it again, it will fall back to the last option /index.php of try_files and initiate an internal "sub-request", which is equivalent to nginx initiating an HTTP request to the http://localhost/index.html
The test is as follows:
This configuration is generally used as a reverse proxy front-end interface setting (vue, angular), because when you click on the front-end page, the URL address of the browser will change, in fact, the browser does not refresh the page and access a new page.Refreshing the browser will report a 404 errorbecause, the path to access does not exist on the physical disk.
Solve the problem that the frontend (Vue) is deployed on Nginx and cannot be refreshed by F5。
Documentation:The hyperlink login is visible.
|