使用 htaccess 编辑 apache 中目录视图的默认标题

发布于 2024-11-02 11:08:41 字数 321 浏览 0 评论 0原文

我正在尝试使用 htaccess 文件来美化 apache 中的默认目录视图。我已经做了几乎所有我想做的事情,除了更改标题的默认措辞。默认情况下,它会显示如下内容:

"Index of [folder_name]"

如果我

# SPECIFY HEADER FILE
HeaderName /apache/header.html

在 htaccess 中使用此:,我可以包含我自己的标题标题,我喜欢它,因为我可以添加 CSS 样式等,但我无法更改我访问的每个文件夹的标题。有办法做到这一点吗?

I'm trying to pretty up the default directory view in apache with an htaccess file. I've done pretty much everything I want to do, except change the default verbiage for the title. By default, it says something like:

"Index of [folder_name]"

and if I use this:

# SPECIFY HEADER FILE
HeaderName /apache/header.html

in htaccess, I can include my own header title, which I like because I can add CSS styling and whatnot, but I cannot make the title change with each folder I visit. Is there a way to do this?

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

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

发布评论

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

评论(3

紫轩蝶泪 2024-11-09 11:08:41

我想这就是我所追求的 - http://httpd.apache.org/docs/ 2.2/env.html

输入此内容作为 h1 标签的标题: 并使用 .shtml 保存标头标签扩展和您的标题变得动态。但是,我仍然希望能够更改措辞 - 摆脱“索引”,并且可能只显示当前目录而不是目录的路径。

I think this is what I was after - http://httpd.apache.org/docs/2.2/env.html

Enter this as the title for your h1 tags: <!--#echo var="REQUEST_URI" --> and save the header with a .shtml tag extension and your titles become dynamic. However, I still would like to be able to change the verbiage - get rid of the "Index of" and maybe have only the current directory show rather than the path to the directory.

弥繁 2024-11-09 11:08:41

您可以指定一个指向生成的页面(例如 mod_includes 或 mod_php)的 HeaderName 并从那里读取环境变量。

或者,您可以提供一些 javascript 来读取当前 url 并设置适当的标题。

mod_dir 无法单独执行此操作。

You could probably specify a HeaderName that points to a generated page (mod_includes, for example, or mod_php) and read the environment variables from there.

Alternatively, you could serve up some javascript that reads the current url and sets the title as appropriate.

mod_dir can't do this on its own.

抽个烟儿 2024-11-09 11:08:41

我认为您需要 IndexOptions +SuppressHTMLPreamble

来自 Apache mod_autoindex 文档

如果 HeaderName 指定的文件包含 HTML 文档的开头( 等) )那么您可能需要设置 IndexOptions +SuppressHTMLPreamble,以便这些标记不重复。

I think you want IndexOptions +SuppressHTMLPreamble.

From the Apache mod_autoindex docs:

If the file specified by HeaderName contains the beginnings of an HTML document (<html>, <head>, etc.) then you will probably want to set IndexOptions +SuppressHTMLPreamble, so that these tags are not repeated.

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