My site www.site.com loads apache2 'It works' page instead of the expected home page of moode which is located at /var/www/html/moodle. There is an index file index.php inside moodle directory but it is not taken by default. If I go to www.site.com/moodle the site homepage comes. The configuration file /etc/apache2/sites-available/site.conf is enabled. How to solve this?
<VirtualHost *:80>
ServerName www.site.com
ServerAlias site.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/moodle
DirectoryIndex index.php
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.site.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI}
[END,NE,R=permanent]
</VirtualHost>
This can be solved by changing the line
DirectoryIndex index.php
to
DirectoryIndex index.php /moodle/index.php
in the file /etc/apache2/sites-available/site.conf.