使用 htaccess 编辑 apache 中目录视图的默认标题
我正在尝试使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我想这就是我所追求的 - 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.您可以指定一个指向生成的页面(例如 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.
我认为您需要
IndexOptions +SuppressHTMLPreamble
。来自 Apache mod_autoindex 文档:
I think you want
IndexOptions +SuppressHTMLPreamble
.From the Apache mod_autoindex docs: