Wednesday, December 23, 2009

Apache directoryindex per virtualhost

SkyHi @ Wednesday, December 23, 2009
I have found the solution! There are literally hundreds of people that have been looking for this solution on the internet and have not posted a solution for the rest of us that run into this problem.

For some reason contrary to the manual my setup only works with an * instead of my ip address.

If you change to an * with out a directory directive you get a permissions error. By making a directory directive "correctly" it will pass you to your correct index.html.

In this example I have not tweaked it yet for security, so beware!

Listen 80

ServerRoot "C:/Apache"

DocumentRoot "C:/Apache/htdocs"

ServerAdmin datapros@our-hosting.net

ServerName 216.51.***.136

Namevirtualhost *

<virtualhost *>
ServerName www.example.com
ServerAdmin datapros@our-hosting.net
DocumentRoot /example
directoryindex index.html
ErrorLog /example/logs/error_log
CustomLog /example/logs/access_log common
</virtualhost>

<virtualhost *>
ServerName www.example2.com
ServerAdmin datapros@our-hosting.net
DocumentRoot /example2
directoryindex index.html
ErrorLog /example2/logs/error_log
CustomLog /example2/logs/access_log common
</virtualhost>

# notice example does not have a "/" in front of it!
<Directory example>
Options FollowSymLinks
AllowOverride All
#None
Order allow,deny
#deny,allow
# Deny from all
Satisfy all
</Directory>

# notice example2 does not have a "/" in front of it!
<Directory example2>
Options FollowSymLinks
AllowOverride All
#None
Order allow,deny
#deny,allow
# Deny from all
Satisfy all
</Directory>



Reference: http://www.webmasterworld.com/apache/3182824.htm