我想通过不同的 uri 存档该服务变量 html 文件,下面是我的配置。
server {
listen 8888;
server_name localhost;
location / {
root html/test
index foo.html
}
location /another {
root html/test
index bar.html
}
}
Run Code Online (Sandbox Code Playgroud)
我想要请求存在于我的测试localhost:8888/another目录中的响应,但我失败了:(bar.html
我该如何修复以上配置,谢谢您的时间。
文件名由指令值root和 URI 构成。所以在这种情况下:
location /another {
root html/test;
index bar.html;
}
Run Code Online (Sandbox Code Playgroud)
该 URI/another/bar.html将位于html/test/another/bar.html。
location如果您希望首先从 URI 中删除指令的值,请使用该alias指令。
location /another {
alias html/test;
index bar.html;
}
Run Code Online (Sandbox Code Playgroud)
该 URI/another/bar.html将位于html/test/bar.html。
有关详细信息,请参阅此文档。
| 归档时间: |
|
| 查看次数: |
2152 次 |
| 最近记录: |