Using RHEL7.9, httpd 2.4.6
I have three sites in my /var/www/html/:
/main
/site1
/site2
The httpd.conf DocumentRoot points to /main
Listen 80
ServerName example.com
DocumentRoot "/var/www/html/main"
IncludeOptional conf.d/*.conf
And I have the following .conf files:
main.conf
<VirtualHost <server ip address>:80>
DocumentRoot "/var/www/html/main/"
ServerName example.com
ServerAlias test.example.com
<Directory /var/www/html/main>
Require all granted
</Directory>
</VirtualHost>
site1.conf
<VirtualHost <server ip address>:80>
DocumentRoot "/var/www/html/site1"
ServerName example.com
ServerAlias test.example.com
<Directory /var/www/html/site1>
Require all granted
</Directory>
</VirtualHost>
site2.conf
<VirtualHost <server ip address>:80>
DocumentRoot "/var/www/html/site2"
ServerName example.com
ServerAlias test.example.com
<Directory /var/www/html/site2>
Require all granted
</Directory>
</VirtualHost>
So basically, all three are sharing identical Vhost configurations except for the DocumentRoot, which points to the respective directories for each site.
When I try to visit the site, I am greeted with /main's index.php, but when I navigate to example.com/site1, I am still seeing main
's index page. Same goes with site 2.
What is wrong with my configuration? Are ServerName and ServerAlias supposed to be different from each VirtualHost?