I have a Centos webserver set up with 2 websites. Initially it only had one website and virtualhost config was added to the end of the httpd.conf file. Not best practice I know however it worked fine and looks as follows.
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
#ServerAdmin admin@example.com
DocumentRoot /var/www/html/example/
ErrorLog /var/log/httpd/example_error.log
CustomLog /var/log/httpd/example_access.log combined
#loglevel warn
<Directory />
#Options Indexes FollowSymLinks
#AllowOverride None
#Require all granted
Options Indexes FollowSymLinks MultiViews
Allowoverride All
Order allow,deny
allow from all
</Directory>
A second development website was added which was a copy of the first one and the virtual host was created just below the first one in the httpd.conf file as follows:
<VirtualHost *:80>
ServerName dev.example.com
ServerAlias dev.example.com
DocumentRoot /var/www/dev.example.com/html
#ErrorLog /var/log/httpd/dev.example.com/error.log
#CustomLog /var/log/httpd/dev.example.com/requests.log combined
<Directory />
#Options Indexes FollowSymLinks
#AllowOverride None
#Require all granted
Options Indexes FollowSymLinks MultiViews
Allowoverride All
Order allow,deny
allow from all
</Directory>
The second virtual host config is definitely being read as it displays the dev website but the directory directives seem to be ignored.
I have also tried making the second directory path explicit i.e.
<Directory /var/www/dev.example.com/html>
However it was ignored again.
Am I missing something in the set up of the second site that will allow the directory directive to be read?
Best Answer
Directory / refers to the root directory of the server. Try Location / to refer to the URL specific to the virtualhost.