我在 nginx 的“sites-available”文件夹中有一个简单的默认网站配置,如下所示。
当我尝试浏览到/hello 时,我希望它为位于我指定的根文件夹中的 index.html 文件提供服务。相反,它试图在我指定的根位置获取 /hello/index.html。
有没有办法告诉 nginx 在不为上下文路径添加前缀的情况下提供文件?
root /var/...;
location / {
...
}
location /hello/ {
root /home/vagrant/public_html/project/dist;
}
Run Code Online (Sandbox Code Playgroud)
使用alias
而不是root
; 引用http://nginx.org/en/docs/http/ngx_http_core_module.html#alias
\n\n\n例如,使用以下配置
\n
location /i/ {\n alias /data/w3/images/;\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n\n\n根据 \xe2\x80\x9c/i/top.gif\xe2\x80\x9d 的请求,将发送文件 /data/w3/images/top.gif。
\n
归档时间: |
|
查看次数: |
9402 次 |
最近记录: |