Virtual Host overlap, defaulting to bad behavior(showing other sites)

Hello all.

I’m building a number of sites and hosting them all on one machine. I’ve had some level of success in doing so with my current configuration, but for some reason, the default behavior for some of the wildcard domains not listed in the files is acting very random and redirecting to an unrelated virtual host. I’m hoping someone can shine a light on the problem as I wasn’t able to find anything when searching this site over google and think I’m doing everything right according to the apache docs.

Cause:
visit http://aRandomUserCreatedUrl.example2.com
Effect:
Be prompted for a login to the svn at http://svn.example1.com (very not cool)

For my each site I have a separate config file in the /etc/httpd/conf.d/ folder. Each of these only carry VirtualHost directives and aliases for folders according to the domain. These are all included when the line in the /etc/httpd/conf/httpd.conf file hits that includes *.conf files in conf.d. No big deal there. Pretty standard stuff.

Here’s an example of what’s in one of these files:

#
# example1.com.conf
#
<VirtualHost *:80>
  ServerName svn.example1.com
  <Location />
    DAV svn
    SVNPath /var/svn/repos/example1.com
    AuthType Basic
    AuthName "svn.example1.com"
    AuthUserFile /var/www/config/svn/example1.com.htpasswd
    Require valid-user
  </Location>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/example1.com/www/
ServerName example1.com
ServerAlias www.example1.com
</VirtualHost>

And another more

#
# example2.com
#
<Directory /var/www/example2.com/trac/htdocs>
    WSGIApplicationGroup %{GLOBAL}
    Order deny,allow
    Allow from all
</Directory>

<Directory "/var/www/example2.com/img/">
    Options Indexes MultiViews
    Order allow,deny
    Allow from all
</Directory>

<Directory "/var/www/example2.com/css/">
    Options Indexes MultiViews
    Order allow,deny
    Allow from all
</Directory>

<Directory "/var/www/example2.com/js/">
    Options Indexes MultiViews
    Order allow,deny
    Allow from all
</Directory>

<VirtualHost *:80>
  ServerName svn.example2.com
  <Location />
    DAV svn
    SVNPath /var/svn/repos/example2.com
    AuthType Basic
    AuthName "svn.example2.com"
    AuthUserFile /var/www/config/svn/example2.com.htpasswd
    Require valid-user
  </Location>
</VirtualHost>

<VirtualHost *:80>
  DocumentRoot /var/www/example2.com/trac/htdocs/
  ServerAlias trac.example2.com
  WSGIScriptAlias / /var/www/example2.com/trac/cgi-bin/trac.wsgi
  <Location "/login">
    AuthType Basic
    AuthName "Trac"
    AuthUserFile /var/www/config/svn/example2.com.htpasswd
    Require valid-user
  </Location>
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /var/www/example2.com/www/
ServerName example2.com
ServerAlias www.example2.com
Alias /img/ "/var/www/example2.com/img/"
Alias /js/ "/var/www/example2.com/js/"
Alias /css/ "/var/www/example2.com/css/"
</VirtualHost>

So, that all works except for the wild card domains not listed in the files.
If you have any thoughts on why this might be happening, please holler, otherwise if I find the solution first, I’ll come back and post it here.

Also open to any questions regarding the sanity or lack there of in this configuration I’ve chosen.

TIA

Adding *.example2.com to the ServerAlias seems to have worked for stopping the overlapping. I’m not entirely sure why it was defaulting to svn for another domain that has no specific ties to it though. Now I just have to get the htaccess working for redirecting these wild card requests.

yeah that worked pretty well. I guess you just have to catch all the subdomains even if you aren’t using them if you have a wildcard dns entry. The HTACCESS bit worked as explained in other threads.