Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个网站,现在用户可以打开一个目录并查看其中的所有文件。我该如何禁用它?
我在考虑 php.ini 文件,或者通常是任何可以解决问题的 php 配置(它是使用 PHP 运行的 Apache 服务器)。
禁用Indexesapache 配置中的选项。
Indexes
将其放在您的站点httpd.conf或.htaccess站点的根目录中。
httpd.conf
.htaccess
Options -Indexes
这样,如果文件夹没有索引页,用户将收到 403 Forbidden 错误。
将名为 .htaccess 的文本文件放入您网站的根目录或您要隐藏的目录,其中包含以下内容: