gpt4 book ai didi

html - Nginx try_files 重定向不服务于 css/图像

转载 作者:行者123 更新时间:2023-11-28 04:38:09 25 4
gpt4 key购买 nike

我正在尝试重定向 https://example.com/user/whatever 下的所有请求到我的“获取我们的应用程序”页面,位于 https://example.com/get_app.html

在我的 nginx.conf 中,我有以下 block 设置:

#Redirect all requests under /user/ to the "get App" page
location /user/ {
try_files $uri $uri/ /get_app.html;
}

提供了 html 文件,但未显示 css 和图像。只是一个带有我的 html 的纯白页。如果我只键入 example.com/user/whatever,该页面将被正确提供。我究竟做错了什么?为什么 nginx 在来自重定向时不能正确提供文件?

最佳答案

最终将我的配置写成:

location /user/ {
return 301 https://example.com/get_app.html;
}

因为使用 try_files 试图从 example.com/user/whatever/css/ 获取 css,我不知道如何解决这个问题。上面的重定向应该足以满足我要实现的目标。

关于html - Nginx try_files 重定向不服务于 css/图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41368522/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com