将Nginx配置为“服务”/&引用;从根目录中已经存在的目录
在/var/www中,我的目录如下:将Nginx配置为“服务”/&引用;从根目录中已经存在的目录,nginx,Nginx,在/var/www中,我的目录如下: /var/www/home /var/www/other /var/www/other2 我希望根目录是/var/www,这样我就可以转到/home或/other,但是我也希望只是/转到/home,我无法理解这一部分 我想我可以为每个位置指定一个根,如: location /{ root /var/www/home; } location /other{ root /var/www/other; } 但我不想每次添加目录时都要更改我的nginx配置。我尝
/var/www/home
/var/www/other
/var/www/other2
我希望根目录是/var/www,这样我就可以转到/home或/other,但是我也希望只是/转到/home,我无法理解这一部分
我想我可以为每个位置指定一个根,如:
location /{ root /var/www/home; }
location /other{ root /var/www/other; }
但我不想每次添加目录时都要更改我的nginx配置。我尝试使用这样的别名,但我只会得到403禁止,我知道这些页面是可以访问的:
server{
root /var/www;
location / {
alias /var/www/home;
}
}
根位置不能指向服务器根目录中的子目录吗
server{
root /var/www;
location = / {
root /var/www/home;
}
location / { }
}
参考: