Py学习  »  NGINX

需要在nginx中使用不同根目录的帮助

ekscrypto • 4 年前 • 503 次点击  

对于一个域,我有一个指向/var/www的站点配置( https://somedomain.com/ )但是我想把一个位置/clientfolder重定向到/home/clientfolder/website/

我的问题是每当有请求出现时,例如 https://somedomain.com/clientfolder/index.html 守护进程正在/home/clientfolder/website/clientfolder/index.html中查找文件

所以我尝试使用rewrite指令:

location /clientfolder {
    rewrite ^/clientfolder/(.*)$ /$1 last;
    root /home/clientfolder/website
}

但是现在 https://somedomain.com/clientfolder/index.html 在/var/www/index.html处加载文件

如果/clientfolder位置匹配,是否有其他指令比rewrite允许我从文件路径中删除“clientfolder”?


最新消息:我设法让它工作,但感觉完全错误:

location /clientfolder/website {
    root /home;
}
location /clientfolder {
    rewrite ^/clientfolder/(.*)$ /clientfolder/website/$1;
}
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/37982
 
503 次点击  
文章 [ 1 ]  |  最新文章 4 年前
Richard Smith
Reply   •   1 楼
Richard Smith    5 年前

如果uri以 /clientfolder 位于 /home/clientfolder/website ,您应该使用 alias 指令。

例如:

location /clientfolder {
    alias /home/clientfolder/website;
}

this document 详情。