Issue
I have a subdomain on an Apache 2.4 web server (an AWS EC2 host), with Indexes set - but it's not displaying the Index at the top level: only in subdirectories. If there is no DirectoryIndex file (index.html) at the top level (http://stuff.example.com), it simply displays the Amazon Linux AMI Test Page. If I have an index.html file at the top level, it's displayed normally.
I've tried to find documentation that Indexes are not displayed for domain pages, and couldn't. Therefore I must be missing something in this basic configuration (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>
Solution
In the AWS EC2 configuration of Apache 2.4 (at least), there is an additional config file /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
Not only does this reveal the nature of the Amazon Linux AMI Test Page, it also explains why this page overrides the directory listing for the root URL of a subdomain: since it's matched by the regular expression in LocationMatch
.
This code is meant to display something useful to the web site visitor if the web admin hasn't added an index page yet... yet it also has the side effect of suppressing directory listings for the root URL of any subdomain. One solution is to comment out, or remove, the Options -Indexes
directive from /etc/httpd/conf.d/welcome.conf
.
Answered By - rphair Answer Checked By - Dawn Plyler (WPSolving Volunteer)