10

如何在没有任何后备的位置指令中返回单个文件?try_files 至少需要两个。这看起来很简单,但我在文档或示例中找不到它。

location / {
      try_files one_file; # => wrong number of parameters
}
4

1 回答 1

13

最简单的方法是在文件不存在时使用重定向到错误代码的功能。

location / {
      try_files /theOnlyFile.html =404;
}
于 2013-10-30T02:39:01.707 回答