Aug 13, 2011
tom

default domain and first domain in apache2 causing trouble

Question

I have 3 sites and a default/test site using mono’s test page.

I created aFirst, c, d, e, zLast. zLast has rewrite rules that should be evaluated last. Since the first VirtualHost seen is the default i set it to this

--aFirst--
<VirtualHost *:80>
    ServerName www.domain.tld
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/test
    DirectoryIndex index.html index.aspx index.php
    MonoDocumentRootDir "/var/www/test"
    MonoServerPath rootsite "/usr/local/bin/mod-mono-server2"
    MonoApplications rootsite "/:/var/www/test"    <Directory /var/www/test>
        MonoSetServerAlias rootsite
        SetHandler mono
        AddHandler mod_mono .aspx .ascx .asax .ashx .config .cs .asmx
    </Directory>
</VirtualHost>

The problem is my default page (the ip address of my server) and the first website (csite.ddomain.net) have problems (even though csite is defined in c and is not the first virtual host). The ip address of my server and csite.ddomain.net ALWAYS load the same site. Either monos test page or the csite. It flips every time i restart apache. Why isnt the server ip address always loading the default page (mono test page) and why isnt csite.ddomain.net always loading the site i want!?!

Heres the config for

--csite--
<VirtualHost *:80>
    ServerName  csite.testdomain.net
    ServerAdmin webmaster@localhost    ServerAlias s.csite.testdomain.net    DocumentRoot /var/www/prjname
    DirectoryIndex index.html index.aspx
    MonoDocumentRootDir "/var/www/prjname"
    MonoServerPath rootsite "/usr/local/bin/mod-mono-server2"
    MonoApplications rootsite "/:/var/www/prjname"    <Directory /var/www/prjname>
        MonoSetServerAlias rootsite
        SetHandler mono
        AddHandler mod_mono .aspx .ascx .asax .ashx .config .cs .asmx
    </Directory></VirtualHost>

aFirst, c, d, e, zLast are all enabled.

Answer

Do you have ‘NameVirtualHost *:80′ defined before all your virtual hosts? Are all your sited listed in one file in order?

Related posts:

  1. Apache virtualhost: requests to domain are served from default directory
  2. Apache2 shared server: default webpage
  3. Why is apache serving the default?
  4. Dummy/default page for apache
  5. Changing default Apache page for a virtual host to a mod_autoindex generated listing

Leave a comment