On accessing a subdomain, it’s gettting redirected to default Apache test page. Upon checking the webroot folder for the subdomain, index file was missing. Upon uploading an index file it worked perfectly. However, I need to enable directory listing for the domain. To achieve this, follow the steps mentioned here:
You are redirecting to Apache test page because, the domains without index file is being redirected to /etc/httpd/conf.d/welcome.conf . I have commented all the lines in the welcome.conf to disable it.
----------
[root@arunlal sub.domain.com]# 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.
#
#<LocationMatch "^/+$">
# Options -Indexes
# ErrorDocument 403 /error/noindex.html
#
------------
Now, the website is loading with a forbidden error page.
Then, we need to enable directory listing for the subdomain. This can be achieved by editing its own configuration file. In plesk, for each domain and subdomain, it have its own configuration file. The next step is how to find the configuration file for a domain.
From default Apache configuration file (/etc/httpd/conf/httpd.conf), we will get an Include file as below:
Include conf.d/*.conf
Then move onto /etc/httpd/conf.d . There you can see various configuration file.
#cd /etc/httpd/conf.d
The configuration file currently we require is something similar to zz***_psa_httpd.conf.
#cat zz***_psa_httpd.conf
There you can see some Include files and the one we need is /etc/httpd/conf/plesk.conf.d/vhosts/*.conf. Now, move on to /etc/httpd/conf/plesk.conf.d/vhosts folder.
#cd /etc/httpd/conf/plesk.conf.d/vhosts
There you can see the configuration files for all your domains and sub-domains. Edit the required configuration file. In my case I need to modify a sub-domain, so
#vi sub.domain.com.conf (sub.domain.com.conf will actually replace your subdomain or domain)
Now, edit it as the following:
Options +FollowSymLinks +Indexes
AllowOverride All
And add a .htaccess file in the webroot directory of the domain which is /var/www/vhosts/sub.domain.com as the following:
#cat .htaccess
----
Options +Indexes
----
That’s it! Now, directory listing will be enabled for your domain.