我想配置nginx以便
http://example.net/
。我明白我需要使用try_files
指令,但我不明白如何实现回退机制。
答案 0 :(得分:0)
经过多次测试后发现。如果未找到静态文件,则会在try_files
的最后一个参数中定义。您可以将该参数设置为内部位置。在我的情况下,我使用
server {
...
root /srv/example.org/web/static;
index index.html;
try_files $uri @redirect-to-dot-net;
location @redirect-to-dot-net {
rewrite ^ http://example.net redirect;
}
}