nginx配置文件中有個location如下:
準備了兩個index文件;
第一個是在/var/www/html目錄中有個index.html,顯示內容爲:
pwd: /var/www/html;
alias /var/www/html/;
第二個是在/var/www/html/img目錄中有個index.html,顯示內容爲:
pwd: /var/www/html/img;
root /var/www/html/;
下面分四種配置情況的展示結果來說明root和alias的區別:
1
配置:使用root,路徑後綴沒有"/";
結果:
2
配置:使用root,路徑後綴有"/";
結果:同上
3
配置:使用alias,路徑後綴有"/";
結果:顯示路徑少了location的img
4
配置:使用alias,路徑後綴沒有"/";
結果: 顯示404