Today I finally figured out the role of root and alias in location configuration, and the difference between them is clear at a glance!
location /img/<span> { alias </span>/var/www/image/<span>; } #若按照上述配置的话,则访问/img/目录里面的文件时,ningx会自动去/var/www/image/目录找文件</span>
location /img/ { root /var/www/image; } #若按照这种配置的话,则访问/img/目录下的文件时,nginx会去/var/www/image/img/目录下找文件。]
alias is the definition of a directory alias, and root is the definition of the top-level directory.
I always thought that root refers to the /var/www/image directory, which should be /var/www/image/img/
Another important difference is that the alias must end with "/", otherwise it will The file cannot be found. . . Root is optional~~
Copyright statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission.
The above has introduced the difference between root and alias of nginx location, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.