title: Domain as fallback to subdomains in apache
body: <p>I have a few subdomains to my domains and I want the domain to work as a fallback if the user writes the wrong subdomain.<br>
  These subdomains works:<br>
  files.myadomain.com, phpmyadmin.mydomain.com and server.mydmomain.com</p>
  
  <p>And the other domains/subdomains return a HTTP 500 error:</p>
  
  <blockquote>
    <p>Request exceeded the limit of 10 internal redirects due to probable
    configuration error. Use 'LimitInternalRecursion' to increase the
    limit if necessary. Use 'LogLevel debug' to get a backtrace.</p>
  </blockquote>
  
  <p>And if I enter a subdomain that doesn't exist I end up in /var/www/</p>
  
  <p>Here is the config:</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
      ServerName files.mydomain.com
      DocumentRoot /var/www/rcane/files.mydomain.com/
  &lt;/VirtualHost&gt;
  
  &lt;VirtualHost *:80&gt;
      ServerName media.mydomain.com
      DocumentRoot /var/www/rcane/media.mydomain.com/
  &lt;/VirtualHost&gt;
  
  &lt;VirtualHost *:80&gt;
      ServerName wordpress.mydomain.com
      DocumentRoot /var/www/rcane/wordpress.mydomain.com/
  &lt;/VirtualHost&gt;
  
  &lt;VirtualHost *:80&gt;
      ServerName myml.mydomain.com
      DocumentRoot /var/www/johan/ayml/
  &lt;/VirtualHost&gt;
  
  &lt;VirtualHost *:80&gt;
      ServerName johan.mydomain.com
      DocumentRoot /var/www/johan/
  &lt;/VirtualHost&gt;
  
  &lt;VirtualHost *:80&gt;
      ServerName phpmyadmin.mydomain.com
      DocumentRoot /usr/share/phpmyadmin/
  &lt;/VirtualHost&gt;
  
  &lt;VirtualHost *:80&gt;
      ServerName sqlbuddy.mydomain.com
      DocumentRoot /var/www/sqlbuddy/
  &lt;/VirtualHost&gt;
  
  &lt;VirtualHost *:80&gt;
      ServerName server.mydomain.com
      DocumentRoot /var/www/
  &lt;/VirtualHost&gt;
  
  &lt;VirtualHost *:80&gt;
      ServerAdmin me@mydomain.com
      ServerName mydomain.com
      ServerAlias *.mydomain.com
      DocumentRoot /var/www/rcane/mydomain.com/
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>Here is the error log with LogLevel debug:</p>
  
  <pre><code>[Sat Apr 28 13:42:24 2012] [debug] core.c(3112): [client 01.254.002.30] r-&gt;uri = /rcane/server.mydomain.com/
  [Sat Apr 28 13:42:24 2012] [debug] core.c(3118): [client 01.254.002.30] redirected from r-&gt;uri = /rcane/server.mydomain.com/
  [Sat Apr 28 13:42:24 2012] [debug] core.c(3118): [client 01.254.002.30] redirected from r-&gt;uri = /rcane/server.mydomain.com/
  [Sat Apr 28 13:42:24 2012] [debug] core.c(3118): [client 01.254.002.30] redirected from r-&gt;uri = /rcane/server.mydomain.com/
  [Sat Apr 28 13:42:24 2012] [debug] core.c(3118): [client 01.254.002.30] redirected from r-&gt;uri = /rcane/server.mydomain.com/
  [Sat Apr 28 13:42:24 2012] [debug] core.c(3118): [client 01.254.002.30] redirected from r-&gt;uri = /rcane/server.mydomain.com/
  [Sat Apr 28 13:42:24 2012] [debug] core.c(3118): [client 01.254.002.30] redirected from r-&gt;uri = /rcane/server.mydomain.com/
  [Sat Apr 28 13:42:24 2012] [debug] core.c(3118): [client 01.254.002.30] redirected from r-&gt;uri = /rcane/server.mydomain.com/
  [Sat Apr 28 13:42:24 2012] [debug] core.c(3118): [client 01.254.002.30] redirected from r-&gt;uri = /rcane/server.mydomain.com/
  [Sat Apr 28 13:42:24 2012] [debug] core.c(3118): [client 01.254.002.30] redirected from r-&gt;uri = /rcane/server.mydomain.com/
  [Sat Apr 28 13:42:24 2012] [debug] core.c(3118): [client 01.254.002.30] redirected from r-&gt;uri = /
  [Sat Apr 28 13:42:24 2012] [debug] mod_deflate.c(615): [client 01.254.002.30] Zlib: Compressed 627 to 379 : URL /rcane/server.mydomain.com/
  </code></pre>