Here is my current setup:
At the bottom of
httpd.conf I have the following:
NameVirtualHost *:80 Include /etc/httpd/conf/vhosts/*
/etc/httpd/conf/vhosts I have the following files:
<VirtualHost *:80> DocumentRoot "/var/www/vhosts/mainsite.com" ServerName mainsite.com ServerAlias www.mainsite.com <Directory "/var/www/vhosts/mainsite.com"> allow from all Options -Indexes </Directory> </VirtualHost>
<VirtualHost *:80> DocumentRoot /var/www/vhosts/sub1.mainsite.com ServerName sub1.mainsite.com <Directory "/var/www/vhosts/sub1.mainsite.com"> allow from all Options -Indexes </Directory> </VirtualHost>
So far so good!
www.mainsite.com both share the same
DocumentRoot (and with some redirection later I can redirect all
www.mainsite.com users to
mainsite.com for SEO).
sub1.mainsite.com also has its own
DocumentRoot and doesn't interfere with anything else.
<Anything that isn't www or sub1>.mainsite.com gets the same
www.mainsite.com get. What I would prefer instead is an error page to come up for any host that doesn't match a
And now for the actual question: What can I tweak to get the desired effect? Also, can the directory rules that are common between the
VirtualHosts be refactored up into
httpd.conf? If so, would I just do something like the following?
<Directory "/var/www/vhosts"> allow from all Options -Indexes </Directory>