【问题标题】:Browser won't show favicon.ico but can browse to it - using Django, nginx gunicorn浏览器不会显示 favicon.ico 但可以浏览到它 - 使用 Django、nginx gunicorn
【发布时间】:2015-02-16 08:58:33
【问题描述】:

这应该很容易,但我解决不了。

我在http://myserver.local/favicon.com 有一个 favicon.ico。我可以在浏览器中输入该 URL,它会在页面上显示图形,但不在菜单栏中。我有点笨,开发仅供个人使用,所以请耐心等待。

我的 index.html 视图包括:

<link rel="shortcut icon" href="http://myserver.local/favicon.ico" type="image/x-icon"/>
<link rel="icon" href="http://myserver.local/favicon.ico" type="image/x-icon"/>

我的任何 nginx myserver.conf 文件目前看起来都是这样的(我已经看到了很多方法):

location = /favicon.ico {
    rewrite (.*) /static/favicon.ico;
}

我尝试了一些不同的标题和 nginx 配置文件变体,但在日志中没有看到任何错误。 Firefox 和 Safari 都无法获取 .ico 文件。

我的配置主要基于this excellent tutorial

【问题讨论】:

    标签: django nginx favicon gunicorn


    【解决方案1】:

    您不应该为此触摸您的 nginx 设置。

    确保您阅读了静态资产在 Django 中的工作原理,并查看回答您问题的答案:How can I get a favicon to show up in my django app?

    【讨论】:

    • 谢谢。我在那个线程上花了一些时间。我不是 100% 确定为什么 {{STATIC_URL}} 在硬编码路径上工作,但最终它工作,这才是最重要的。谢谢garbanzio。
    猜你喜欢
    • 2013-10-06
    • 2012-04-19
    • 1970-01-01
    • 2013-06-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多