Home >Operation and Maintenance >Nginx >What is the difference between root and alias in Nginx

What is the difference between root and alias in Nginx

WBOY
WBOYforward
2023-05-16 17:31:141245browse

Project structure

The Nginx directory structure is as follows: html is the deployed front-end project page, respectively zuiyu and test, below I will access <pre class="brush:plain;">nginx --conf --logs --html --zuiyu --index.html --static --test --index.html --static</pre>test by using

root

and

alias

to access zuiyuproject

  location /zuiyu {
    root html;
    index index.html;
  } 
  location /zuiyu {
    alias html/zuiyu;
    index index.html;
  }

accesstestproject

 location /test {
    root html;
    index index.html;
  } 
  location /test {
    alias html/test;
    index index.html;
  }

Summary

Through the above two small examples, I believe everyone has also seen that root and alias# The difference between ##, yes alias is an alias, that is, when using alias to configure the project address, you can directly configure it to the accessed project folder, and use rootWhen configuring, Nginx will find the folder matching uri under the default deployment path html, and then search for index.html under the folder.

The above is the detailed content of What is the difference between root and alias in Nginx. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete