Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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>
share|improve this question
    
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 8:42

1 Answer 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>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.