Apache配置支持目录浏览

 

主配置文件 httpd.conf 中修改:

1)添加支持模块

LoadModule autoindex_module modules/mod_autoindex.so

LoadModule dir_module modules/mod_dir.so

注意一定要拥有这两个模块,否则下面的配置不生效,返回404 Not Found错误。

这个模块也有可能直接编译到Apache核心文件httpd中去了。

可以使用httpd –l 查看是否静态包含了这个模块。

如果不存在就在modules文件夹中查看是否拥有这个模块。

2)为DocumentRoot目录添加Options Indexes,即可生成目录

<Directory "/usr/local/apache2/htdocs">

Options Indexes FollowSymLinks

</Directory>

这里Indexes控制是否打开目录浏览,如果要关闭目录浏览,使用

Option -Indexes

3)加载 httpd-autoindex.conf 配置

Include conf/extra/httpd-autoindex.conf

在配置文件httpd-autoindex.conf中的修改:

IndexOptions FancyIndexing HTMLTable VersionSort NameWidth=* FoldersFirst Charset=UTF-8 SuppressDescription SuppressHTMLPreamble

其中

FancyIndexing 支持美化显示;

HTMLTable 允许底层代码把文件列表生成在一个table元素里面;

VersionSort 安装版本排序;

NameWidth=* 页面自动匹配文件名宽度;

FoldersFirst 安装文件夹优先排列;

Charset=UTF-8 支持中文显示;

SuppressDescription 不显示文件描述;

最后一个忘记是什么了,去看apache 官网的说明。。。

2.apache  原生目录实在难看 。还好有改善的方法。网上有 H5AI 的模版可以下载使用。但现在是用在嵌入式平台,资源有限,只做了参考。

1)apache提供配置两个文件,以便修饰页面。

# ReadmeName is the name of the README file the server will look for by

# default, and append to directory listings.

#

# HeaderName is the name of a file which should be prepended to

# directory indexes. 

ReadmeName /footer.shtml (文件前必须加/,使用绝对路径,否则子目录无法继承该文件)

HeaderName /header.shtml

这两个文件放于DocumentRoot目录下。

原文地址:https://www.cnblogs.com/reachos/p/9075281.html