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

标签 linux apache

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

相关文章:

apache - 在 Ubuntu 中运行多个独立的 Flask 应用程序

python - 在 Eclipse 中为远程系统资源管理器启用 pep8

c - linux kernel convert char * to uint8_t[6] (读字符串到mac)

c - 编写我自己的 shell,未声明的标识符 "output"

linux - mod_rewrite 已启用但无法正常工作

apache - 在使用 mod_rewrite 的 Apache .htaccess 文件中,是否可以为域强制 www 和强制 https?

apache - 使用 mod_remoteip 获取 Apache 2.4 访问日志以显示客户端 IP,而不是使用 Varnish 的 127.0.0.1

linux - 如何确认 SFTP 文件传送?

PHP5.3(作为Apache模块)无法写入/var/www/<project-name>/<document-root>/cache

php加密的ssl session 数据