所有子域子目录中的网站图标

发布于 2024-10-01 09:57:07 字数 496 浏览 0 评论 0原文

我习惯将 favicon.ico 保存在 public_html 文件夹中以添加 favicon。

我现在遇到的问题是,我想显示某个子目录的所有文件( example.com/example "onwards" ),只是把它放在那里,似乎并不能完成这项工作。

我知道我可以逐个文档并添加:

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

但我希望有一种更实用的方法,首先我认为可能有一种通过 CSS 的方法,但情况似乎并非如此。

这会派上用场,因为每个文档都已经包含:

<link rel="stylesheet" type="text/css" href="test.css" />

那么有什么想法或解决方法来解决这个问题吗?

I am used to just save the favicon.ico in the public_html folder for adding the favicon.

The problema I have now is that I want to display the in all the files of a certain subdirectory, ( example.com/example "onwards" ) just putting it there, doesnt seem to do the job.

I know I could go document by document and add:

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

But I hope there is a more practical way, first I thought there might be a way trough CSS but that doesnt seem to be the case.

This would have come in handy because every document already includes:

<link rel="stylesheet" type="text/css" href="test.css" />

So any ideas or workarounds to how to solve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

记忆之渊 2024-10-08 09:57:07

您必须使用 link rel=... 表示法指定网站图标。

浏览器将仅在域的根目录中搜索默认的 /favicon.ico。您必须明确指定的任何变化。

You will have to specify the favicon using the link rel=... notation.

Browsers will search only in the root directory of the domain for a default /favicon.ico. Any variations from that you have to specify explicitly.

听,心雨的声音 2024-10-08 09:57:07

添加 元素是正确的方法。使用模板引擎(例如Template-Toolkit)以避免手动复制常见内容。

Adding the <link> element is the right way to go. Use a template engine (e.g. Template-Toolkit) to avoid duplicating common content manually.

山有枢 2024-10-08 09:57:07

这可能不是最优雅的方式,我来这里是为了寻找解决方案。
不幸的是,给出的答案不适合我。

就我而言,我在本地主机上工作(通过私有IP),

这就是我所做的:

        <link rel="icon" href="<?php echo rtrim($_SERVER['PHP_SELF'], basename($_SERVER['PHP_SELF'])); ?>favicon.ico" type="image/x-icon">

It might not be the most elegant way, and i came here to find a solution.
Unfortunaly the given answers did not suited for me.

In my case i working on a localhost (via private ip)

this is what i did :

        <link rel="icon" href="<?php echo rtrim($_SERVER['PHP_SELF'], basename($_SERVER['PHP_SELF'])); ?>favicon.ico" type="image/x-icon">
孤城病女 2024-10-08 09:57:07

正如上面提到的,不要浪费时间在搜索上。在这种情况下是唯一的方法。当您要检查标记更改的结果时,请记住浏览器缓存可能很棘手。

As mentioned above don't waste time on searching. is the only way in that case. When you will be checking out results of your markup changes, remember that browser cache can be tricky.

来日方长 2024-10-08 09:57:07

将所有子域的 favicon.ico url 重定向到 public_html 的 favicon.ico

即。 subdomain.website.com/favicon.ico 应转到 www.website.com/favicon.ico

redirect favicon.ico url for all subdomains to public_html's favicon.ico

ie. subdomain.website.com/favicon.ico should go to www.website.com/favicon.ico

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文