如何将表单的 URI 映射staging.example.com/siteA到位于的虚拟服务器/var/www/siteA?
主要限制是我不想为 siteA 创建子域。到目前为止,我看到的所有 nginx.conf 示例都依赖于有一个子域来进行映射。
谢谢
如何将表单的 URI 映射staging.example.com/siteA到位于的虚拟服务器/var/www/siteA?
主要限制是我不想为 siteA 创建子域。到目前为止,我看到的所有 nginx.conf 示例都依赖于有一个子域来进行映射。
谢谢
您可以在块中使用root 指令location,如下所示:
server {
server_name staging.example.com;
root /some/other/location;
location /siteA/ {
root /var/www/;
}
}
然后http://staging.example.com/foo.txt指向/some/other/location/foo.txt,同时http://staging.example.com/siteA/foo.txt指向/var/www/siteA/foo.txt。
请注意,该siteA目录仍应存在于文件系统上。如果要http://staging.example.com/siteA/foo.txt指向/var/www/foo.txt,则必须使用alias指令:
location /siteA/ {
alias /var/www;
}