即使索引文件存在,我如何configurationApache来列出目录中的文件?
例如,如果我有一个包含许多文件的目录/var/foo ,其中一个是目录索引(index.html,index.php等),我怎样才能让Apache显示目录列表显示index.html的内容,当用户浏览到http://example.com/foo/ ?
# Directory listing for /var/foo/, mapped to http://example.com/foo/ .. . code.c readme.pdf index.html
我用了以下,但我会想象有一个更好的方法:
Options +Indexes +MultiViews DirectoryIndex will-never-exist.xyz
您可以将DirectoryIndex选项留空或只closuresdir_module模块。
DirectoryIndex指令可以限制在一个目录块的范围内
<Directory /path/to/directory/to/list> Options +Indexes +MultiViews DirectoryIndex will-never-exist.xyz </Directory>
这限制了范围到特定的目录,而不是你的虚拟主机或服务器等