apache - Apache HTAccess 未将 HeaderName 和 FooterName 应用于索引
问题描述
我目前正在尝试为将使用它的文件夹建立索引。我遇到的问题是HeaderName
and te FooterName
。它们只是不适用于索引。 该header.html
文件包含以下内容:
<html>
<head>
<title>My Stuff</title>
<style type="text/css">
body {
background: #eee;
margin: 33px;
color: #333;
}
</style>
</head>
该.htaccess
文件具有以下内容:
# enable indexes
Options +Indexes
# htaccess protection
<Files ~ "^.*\.([Hh][Tt][Aa])">
order allow,deny
deny from all
</Files>
# directory customization
<IfModule mod_autoindex.c>
# index options
IndexOptions IgnoreCase
IndexOptions FancyIndexing
IndexOptions FoldersFirst
IndexOptions NameWidth=*
IndexOptions DescriptionWidth=*
IndexOptions SuppressHTMLPreamble
# display order
IndexOrderDefault Descending Name
# page customization
HeaderName header.html
ReadmeName footer.html
# ignore page customization files and others
IndexIgnore header.html footer.html favicon.ico .htaccess .ftpquota .DS_Storeicons *.log *,v *,t .??* *~ *# errorlog
</IfModule>
我怎样才能解决这个问题?我只是无法让它工作并清除了我的缓存(多次),我也在其他浏览器上尝试过。我一直在关注如何设置它的教程(因为我不熟悉.htaccess
文件和相关的东西)。
我从索引中获得的 HTML 源代码与默认值相同,因此我无法判断它是否在做任何事情。我也可以说所有的东西都在游戏文件夹中,因此更加混乱。
我不确定我正在使用的主机/面板运行的是什么 Apache 版本,但不显示它。我环顾四周,找不到它。它很可能是最常用的一个,因为我在它上面所做的大多数事情都没有错误。我也没有收到任何错误.htaccess
。
解决方案
我只是在调查 IndexOptions 时发现了这一点,并决定进行测试。
它似乎对我有用(Chrome,在 hostpapa.com 上使用 LAMP 服务器)
演示:http ://www.wsurvey.org/stackOverflow/testIndexOptions/
您可以查看页面源以验证 SuppressHTMLPreamble 是否有效
.htaccess :
# test of indexOptions
Options +Indexes
<IfModule mod_autoindex.c>
# index options
IndexOptions IgnoreCase
IndexOptions FancyIndexing
IndexOptions FoldersFirst
IndexOptions NameWidth=*
IndexOptions DescriptionWidth=*
IndexOptions SuppressHTMLPreamble
# display order
IndexOrderDefault Descending Name
# page customization
HeaderName header.html
ReadmeName readme.txt
# ignore page customization files and others
IndexIgnore header.html footer.html favicon.ico .htaccess .ftpquota .DS_Storeicons *.log *,v *,t .??* *~ *# errorlog
</IfModule>
并且 header.html 是(丑陋,但表明它有效)
<html>
<head>
<title>This is a title</title></title>
<style type="text/css">
body,.foo {
background: tan;
margin: 33px;
color: blue;
}
.foo {
background:cyan;
}
</style>
</head>
<body>
<div class="foo" >This is content in header.html !</div>
推荐阅读
- go - 将接口转换为 int64 无法按预期工作
- sed - 当字符串中有空格时,sed 查找和替换失败
- vba - 使用VBA从搜索网页的结果中提取表格
- javascript - 如何将“ref”添加到嵌入式嵌套反应组件
- reactjs - CoreUI-free-react-admin-template 不工作
- python - Google Foobar escape-pods 测试用例 N. 4 失败
- javascript - 导航中的间距
- reactjs - 如何只重新渲染一个单元格?
- html - Github页面上的损坏图像
- javascript - 如何在javascript / jquery中获取div的指定高度