Home > Article > Backend Development > The usage of Nginx's alias and the difference between it and root
The usage of Nginx’s alias and the difference from root
http://nginx.org/en/docs/http/ngx_http_core_module.html#alias
http://nginx.org/en/docs/http/ngx_http_core_module.html#root
I used to only know how to use root in the location block of Nginx, but I always felt that using it could not satisfy some of my own ideas. Then I finally discovered alias.
Let’s look at the usage of toot first
<code>location <span>/request_path/image/</span> { root <span>/local_path/image/</span>; }</code>
The result of this configuration is that when the client requests /request-path/image/cat.png,
Nginx maps the request to /local_path/image/request-path/image/cat.png
Look at the usage of alias
<code>location /request_path/<span>image</span>/ { <span>alias</span> /local_path/<span>image</span>/; }</code>
At this time, when the client requests /request-path/image/cat.png,
Nginx maps the request to /local_path/image/cat.png
You can know how to use it by comparing root~~ :)
The above introduces the usage of Nginx's alias and the difference with root, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.