gpt4 book ai didi

linux - 拒绝访问除索引文件之外的所有文件 - Apache2

转载 作者:太空宇宙 更新时间:2023-11-04 11:35:56 25 4
gpt4 key购买 nike

我正在配置 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com