如何在 WAMP Server 3 的虚拟主机中启用目录列表

How to enable directory listing in a virtual host of WAMP Server 3

我在我的本地机器上使用 wamp 服务器 3。每当我创建一个虚拟主机时,我必须至少提供一个 index.php 文件来访问我的项目目录,没有它我会收到 404 错误。

但我也想在不提供 index 文件的情况下访问我的项目目录。当服务器找不到索引文件时,我喜欢查看目录列表。就像下图:

我认为问题出在我的 httpd-vhost.conf 文件中。这是我要启用目录列表的目录的虚拟主机配置:

<VirtualHost *:80>
    ServerName virtualhost.info
    DocumentRoot c:/wamp64/www/virtual_host_test
    <Directory  "c:/wamp64/www/virtual_host_test/">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

如有任何帮助,我们将不胜感激。

试试这个...

<VirtualHost *:80>
  ServerName virtualhost.info
  DocumentRoot c:/wamp64/www/virtual_host_test
  <Directory  "c:/wamp64/www/virtual_host_test/">
    Options +Indexes +FollowSymLinks +MultiView
      AllowOverride All
      Require local
   </Directory>
</VirtualHost>

注意 Indexes 选项开头的 +。您还应该阅读此内容。

https://wiki.apache.org/httpd/DirectoryListings

找到一个解决方案。

默认情况下,New Wamp 禁用 Fancy 目录列表。

编辑C:\wamp64\bin\apache\apache2.4.17\conf\httpd.conf

需要加载这个模块(去掉#)

LoadModule autoindex_module modules/mod_autoindex.so

需要加载此 conf(删除 #)

Include conf/extra/httpd-autoindex.conf

参考链接:WAMP is not displaying the icons in the directory listing

谢谢

如果您想启用 目录浏览,只需在VirtualHost

下执行此操作
Options +Indexes +FollowSymLinks +MultiViews
#Options -Indexes

对于禁用这个功能,你只需撤销:

#Options +Indexes +FollowSymLinks +MultiViews
 Options -Indexes