从 httpd 2.4.10 开始,仅使用 httpd.conf 是不可能的
因为列标题是硬编码的
模块/生成器/mod_autoindex.c.
我使用 httpd.conf 和 JavaScript 更改了标题。这不是一个完整的解决方案,因为它仅适用于一种语言。我一直无法弄清楚如何为几种语言做同样的事情。遗憾的是,无法使用“document.documentElement.lang”来检测适当的语言,因为 mod_autoindex.c 不提供“lang”属性。
以下是我的 httpd.conf 中的相关行(您可以省略 IndexOptions 中除 HTMLTable 之外的所有内容):
LoadModule autoindex_module /usr/lib/httpd/modules/mod_autoindex.so
IndexOptions HTMLTable Charset=UTF-8 SuppressDescription
IndexStyleSheet "/DirectoryIndex.css"
ReadmeName "/DirectoryIndexFooter.html"
请注意,即使您不需要样式表,也不能省略 IndexStyleSheet 指令。样式表文件不必存在。
这是我的 /DirectoryIndexFooter.html:
<script>
document.title = document.title.replace ('Index of', 'Sisukord:');
var elem = document.getElementById ('indextitle');
elem.innerHTML = elem.innerHTML.replace ('Index of', 'Sisukord:');
elem = document.getElementsByClassName ('indexcolname') [0];
elem.innerHTML = elem.innerHTML.replace ('Name', 'Nimi:');
elem = document.getElementsByClassName ('indexcollastmod') [0];
elem.innerHTML = elem.innerHTML.replace ('Last modified', 'Viimane muutmine:');
elem = document.getElementsByClassName ('indexcolsize') [0];
elem.innerHTML = elem.innerHTML.replace ('Size', 'Suurus:');
</script>