我正在配置 Apache2 服务器,但我无法弄清楚如何拒绝访问除索引文件之外的所有文件/目录。
我的网站位于/var/www/
这是我当前在/etc/apache2/apache2.conf 文件中的设置:
<Directory />
Order Deny,Allow
Deny from all
Options None
AllowOverride None
</Directory>
<Directory /var/www/>
Order Allow,Deny
Allow from all
</Directory>
我该如何解决我的问题?谢谢!
最佳答案
尝试添加 <FilesMatch>
对于 index.php。如果在此位置不起作用,请将其移到目录的 Deny from all
上方。 .更改 index.html
无论您的索引文件是什么。
<Directory />
Order Deny,Allow
Deny from all
Options None
AllowOverride None
</Directory>
<Directory /var/www/>
# Deny first, then allow
Order deny,allow
# Deny everyone from everything
Deny from all
<FilesMatch index\.html>
# but allow index.html
Allow from all
</FilesMatch>
</Directory>
关于linux - 拒绝访问除索引文件之外的所有文件 - Apache2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7891478/