要阻止使用目录索引,可以使用Apache 2.4的
Options -Indexes
DirectoryIndex index.html
Order Deny,Allow
Deny from all
在上述示例中,我们假设/var/www/html是您网站的根目录。首先,使用Options -Indexes指令禁用目录索引。然后,通过DirectoryIndex指令设置默认的索引文件为index.html。
接下来,使用
通过这样的配置,Apache将禁止目录索引,并且只允许访问index.html文件。其他的.php和.html文件将被禁止访问。您可以根据需要修改