域级别的目录列表 (Apache)
Directory Listing at domain level (Apache)
我在 Apache 2.4 网络服务器(AWS EC2 主机)上有一个子域,设置了索引 - 但它没有在顶层显示索引:仅在子目录中显示。如果顶层 (http://stuff.example.com) 没有 DirectoryIndex 文件 (index.html),它只会显示 Amazon Linux AMI 测试页。如果我在顶层有一个 index.html 文件,它会正常显示。
我试图找到有关域页面不显示索引的文档,但找不到。因此我必须在这个基本配置中遗漏一些东西(httpd.conf):
<Directory "/data/stuff">
AllowOverride Indexes AuthConfig
Require all granted
</Directory>
<VirtualHost *:80>
ServerName stuff.example.com
DocumentRoot /data/stuff
Options +Indexes +FollowSymLinks
</VirtualHost>
在 Apache 2.4(至少)的 AWS EC2 配置中,有一个额外的配置文件 /etc/httpd/conf.d/welcome.conf
:
<LocationMatch "^/+$">
Options -Indexes
ErrorDocument 403 /.noindex.html
</LocationMatch>
<Directory /var/www/noindex>
AllowOverride None
Require all granted
</Directory>
Alias /.noindex.html /var/www/noindex/index.html
这不仅揭示了 Amazon Linux AMI 测试页面 的本质,还解释了为什么该页面会覆盖根目录列表 URL 的子域:因为它与 LocationMatch
.
中的正则表达式匹配
如果网络管理员还没有添加索引页面,此代码旨在向网站访问者显示一些有用的东西......但它也有抑制根目录列表的副作用URL 的任何子域。一种解决方案是从 /etc/httpd/conf.d/welcome.conf
.
中注释掉或删除 Options -Indexes
指令
您可以设置自己的 DirectoryIndex,它将覆盖默认值。
<VirtualHost *:80>
ServerName stuff.example.com
DocumentRoot /data/stuff
DirectoryIndex index.php
Options +Indexes +FollowSymLinks
</VirtualHost>
我在 Apache 2.4 网络服务器(AWS EC2 主机)上有一个子域,设置了索引 - 但它没有在顶层显示索引:仅在子目录中显示。如果顶层 (http://stuff.example.com) 没有 DirectoryIndex 文件 (index.html),它只会显示 Amazon Linux AMI 测试页。如果我在顶层有一个 index.html 文件,它会正常显示。
我试图找到有关域页面不显示索引的文档,但找不到。因此我必须在这个基本配置中遗漏一些东西(httpd.conf):
<Directory "/data/stuff">
AllowOverride Indexes AuthConfig
Require all granted
</Directory>
<VirtualHost *:80>
ServerName stuff.example.com
DocumentRoot /data/stuff
Options +Indexes +FollowSymLinks
</VirtualHost>
在 Apache 2.4(至少)的 AWS EC2 配置中,有一个额外的配置文件 /etc/httpd/conf.d/welcome.conf
:
<LocationMatch "^/+$">
Options -Indexes
ErrorDocument 403 /.noindex.html
</LocationMatch>
<Directory /var/www/noindex>
AllowOverride None
Require all granted
</Directory>
Alias /.noindex.html /var/www/noindex/index.html
这不仅揭示了 Amazon Linux AMI 测试页面 的本质,还解释了为什么该页面会覆盖根目录列表 URL 的子域:因为它与 LocationMatch
.
如果网络管理员还没有添加索引页面,此代码旨在向网站访问者显示一些有用的东西......但它也有抑制根目录列表的副作用URL 的任何子域。一种解决方案是从 /etc/httpd/conf.d/welcome.conf
.
Options -Indexes
指令
您可以设置自己的 DirectoryIndex,它将覆盖默认值。
<VirtualHost *:80>
ServerName stuff.example.com
DocumentRoot /data/stuff
DirectoryIndex index.php
Options +Indexes +FollowSymLinks
</VirtualHost>