运行 Centos 7 和 Apache 2.4。使用虚拟主机设置存储库,我希望能够显示index.html
文档根目录中的非文件和目录。但是当我在浏览器中访问它时,我得到了 Apache 测试页面。因此,我查看/etc/httpd/conf.d/welcome.conf
并发现我需要做的就是注释掉所有行(对其进行测试,它的工作原理如广告所示)。但我想在所有站点上保留此功能,而不是在这个单一虚拟主机上。
如何在每个虚拟主机的基础上禁用欢迎页面?
[michael@mybox main]$ cat /etc/httpd/conf.d/welcome.conf
#
# This configuration file enables the default "Welcome" page if there
# is no default index page present for the root URL. To disable the
# Welcome page, comment out all the lines below.
#
# NOTE: if this file is removed, it will be restored on upgrades.
#
<LocationMatch "^/+$">
Options -Indexes
ErrorDocument 403 /.noindex.html
</LocationMatch>
<Directory /usr/share/httpd/noindex>
AllowOverride None
Require all granted
</Directory>
Alias /.noindex.html /usr/share/httpd/noindex/index.html
Alias /noindex/css/bootstrap.min.css /usr/share/httpd/noindex/css/bootstrap.min.css
Alias /noindex/css/open-sans.css /usr/share/httpd/noindex/css/open-sans.css
Alias /images/apache_pb.gif /usr/share/httpd/noindex/images/apache_pb.gif
Alias /images/poweredby.png /usr/share/httpd/noindex/images/poweredby.png
[michael@mybox main]$
答案1
在适当的虚拟主机中覆盖它
<LocationMatch "^/+$">
Options +Indexes
</LocationMatch>