【发布时间】:2020-02-11 02:48:24
【问题描述】:
我正在尝试在 nginx 上提供一个 jekyll 博客。 构建目录中的文件应该可以通过以下路径访问:
- index.html -> /
- 1.0/
- index.html -> /1.0/
- foo/
a.html -> /1.0/foo/a/
b.html -> /1.0/foo/b/
c.html -> /1.0/foo/c/
- bar/
1.html -> /1.0/bar/1/
2.html -> /1.0/bar/2/
我尝试在 nginx 中使用 try_files 指令,但它总是调用回退,尽管文件可用。这是配置:
location ~* ^(.+)/$ {
try_files $uri /$1/index.html /$1.html =404;
}
如果我删除 404 后备,它仅适用于最后一个值。
所以我的问题是:配置 nginx 以提供这样的静态文件的最佳方式是什么?
【问题讨论】:
标签: nginx jekyll static-files