在我们的服务器上,我们有包含所有代码的/var/www/root/html/web/
目录以及包含我们的静态前端代码的/var/www/root/html/web/front/
。Nginx根目录位置
我们的前端只有通过REST API调用,有/api/
前缀码通信,因此,所有的呼叫都将通过ourdomain.com/api/products/
,ourdomain.com/api/products/45
等访问。我们也有一个管理员在那里运行,在ourdomain.com/admin
当我们想看到实际的前端,我们必须在浏览器中去ourdomain.com/front
,这当然不是我们想要的。
我们有,除其他东西,这在我们的配置:
root /var/www/html/web;
index index.php index.html;
location /front {
# some magic to make sure the /front folder will not be parsed
index nothing_will_match;
autoindex on;
}
然而,我们想的是,如果你去ourdomain.com
它会加载/var/www/html/web/front/
文件夹根目录,如果你去ourdomain.com/api/*
或ourdomain.com/admin/*
它将以root身份加载/var/www/html/web/
。那可能吗?
注:/var/www/html/web/front/
文件夹可以移动别的地方如果需要的话,到/var/www/html/front/
例如