0

My main website is working correctly but I'm trying to setup a subdomain, but it always shows the main website instead, i've copied the main section of my apache2.conf below

# Include the virtual host configurations:
Listen 80

# This is the "main" server running on 67.208.112.97
DocumentRoot /var/www

# This is the other address
NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot /var/www
ServerName giantpixels.com.au
<Directory “/var/www”>
allow from all
Options +Indexes
</Directory>
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /home/gardenbook/wwwroot/gardenbook
ServerName garden.giantpixels.com.au
<Directory “/home/gardenbook/wwwroot/gardenbook”>
allow from all
Options +Indexes
</Directory>
</VirtualHost>
  • Could you please comment out both `Directory` configs you have in each `VirtualHost`, restart apache and try to access the websites ? Also could you please check `/var/log/httpd/error_log` or where your apache dumps the errors to see if anything is showing up in there. – Prix Aug 21 '10 at 08:42

1 Answers1

1

You can't mix VirtualHosts and non-VirtualHosts. Remove the DocumentRoot directive from your main Apache httpd configuration and add a default VirtualHost block instead:

# Include the virtual host configurations:
Listen 80

# This is the other address
NameVirtualHost *:80

# This VirtualHost will also be served when no Host
# header was provided or the hostname is unknown.
# See
#  http://httpd.apache.org/docs/2.2/vhosts/details.html
<VirtualHost *:80>
  DocumentRoot /var/www
  ServerName giantpixels.com.au
  <Directory “/var/www”>
    allow from all
    Options +Indexes
  </Directory>
</VirtualHost>

<VirtualHost *:80>
  DocumentRoot /home/gardenbook/wwwroot/gardenbook
  ServerName garden.giantpixels.com.au
  <Directory “/home/gardenbook/wwwroot/gardenbook”>
    allow from all
    Options +Indexes
  </Directory>
</VirtualHost>
joschi
  • 21,387
  • 3
  • 47
  • 50