【发布时间】:2016-01-17 14:35:44
【问题描述】:
在我们的服务器上,/var/www/root/html/web/ 目录包含所有代码,/var/www/root/html/web/front/ 包含我们的静态前端代码。
我们的前端仅通过具有 /api/ 前缀的 REST 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,它将以 root 身份加载 /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/
【问题讨论】:
标签: nginx configuration location vhosts