Apache-Httpd
僅針對特定虛擬主機禁用 Apache 歡迎頁面?
執行帶有 Apache 2.4 的 Centos 7。使用虛擬主機設置儲存庫,我希望能夠
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]$
在適當的虛擬主機中覆蓋它
<LocationMatch "^/+$"> Options +Indexes </LocationMatch>