我在尝试给我网站新建一个子域名网站时,配置nginx遇到了问题,我想将我的静态文件指定到某个路径下,但是遇到了问题
1Panel 版本:社区版1.10.5-lts
操作系统:ubuntu
关键截图:
日志:
没有添加
# 前端路由 - 使用精确匹配避免循环
location = / {
try_files /index.html =404;
}
location / {
try_files $uri $uri/ @fallback;
}
location @fallback {
rewrite ^.*$ /index.html last;
}
时报下面的错误:
==> error.log <==
2025/10/16 10:59:15 [error] 317#317: *46965965 rewrite or internal redirection cycle while internally redirecting to “/index.html”, client: 219.144.137.232, server: tools.hahaguai.cn, request: “GET / HTTP/1.1”, host: “tools.hahaguai.cn”
添加了之后 页面404,access.log:
127.0.0.1 - - [16/Oct/2025:11:03:24 +0800] “GET / HTTP/1.1” 404 150 “-” “curl/7.58.0”