apache 2.4.1 配置文件目录浏览并优化显示

来源:互联网 发布:码盘淘宝 编辑:程序博客网 时间:2024/06/06 14:08

一.目录浏览的配置。

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

1)添加支持模块。

LoadModule autoindex_module modules/mod_autoindex.so

LoadModule dir_module modules/mod_dir.so

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

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

options Indexes FollowSymLinks

</Directory>

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目录下。

2)如果制作这两个文件基本与底层无关了。可以参考:

http://www.360doc.com/content/12/0113/22/3130130_179259431.shtml

原创粉丝点击