Apache (定制) 目录索引
时间:2006-02-10 来源:f980215
无此参数, 在无 index.html 文件时, 将不显示目录
The DirectoryIndex directive sets the list of resources to look for, when the client requests an index of the directory by specifying a / at the end of the directory name. Local-url is the (%-encoded) URL of a document on the server relative to the requested directory; it is usually the name of a file in the directory. Several URLs may be given, in which case the server will return the first one that it finds. If none of the resources exist and the Indexes option is set, the server will generate its own listing of the directory.
Example
DirectoryIndex index.html
then a request for http://myserver/docs/ would return http://myserver/docs/index.html if it exists, or would list the directory if it did not.
另:定制 Apache index 目录
在 Apache 中设置目录 <Directory> 有 Options Indexes 属性的时候,可以索引文件夹内容,但是如果要定制显示的内容,就必须添加以下几行到各个服务器的设置中去。(可以是全局,也可以是虚拟服务器或者目录) MODULE: mod_autoindex
ReadmeName /README.shtml
HeaderName /HEADER.shtml
IndexOptions +SuppressHTMLPreamble FancyIndexing \
VersionSort FoldersFirst NameWidth=* (Optoional)
Filename must resolve to a document with a major content type of text/* ( e.g. , text/html , text/plain , etc.). This means that filename may refer to a CGI script if the script's actual file type (as opposed to its output) is marked as text/html such as with a directive like:
AddType text/html .cgi
Content negotiation will be performed if Options MultiViews is in effect. If filename resolves to a static text/html document (not a CGI script) and either one of the options Includes or IncludesNOEXEC is enabled, the file will be processed for server-side includes (see the mod_include documentation).
新添加一个种后缀名为 README 和 HEADER 专用:
AddType text/html .shtml
然后修改 README.html 和 HEADER.html 为 README.shtml 和 HEADER.shtml 即可。要注意的是,因为我要列出的目录都为 open source, 所以有很多名字为“ README ”的文件。因此,要将其中的一条配置做小小的修改。(就是隐藏某些文件的配置)
IndexIgnore .??* *~ *# HEADER.* README.* RCS CVS *,v *,t