Home > Backend Development > PHP Tutorial > The difference between root and alias of nginx location

The difference between root and alias of nginx location

WBOY
Release: 2016-08-08 09:21:21
Original
1104 people have browsed it

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>
Copy after login
location /img/ {
    root /var/www/image;
}
#若按照这种配置的话,则访问/img/目录下的文件时,nginx会去/var/www/image/img/目录下找文件。] 
Copy after login

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.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template