title: Apache VirtualDocumentRoot best setting
body: <p>I want to have a clean, efficient directory setup with VirtualDocumentRoot. (Reference: <a href="http://httpd.apache.org/docs/2.0/mod/mod_vhost_alias.html" rel="nofollow">http://httpd.apache.org/docs/2.0/mod/mod_vhost_alias.html</a>).</p>
  
  <p>In particular, I am thinking of the following:</p>
  
  <p>1) <a href="http://example.com" rel="nofollow">http://example.com</a>  to be served by /apache_root/example.com</p>
  
  <p>2) <a href="http://www.example.com" rel="nofollow">http://www.example.com</a>  to be served by     /apache_root/www/example.com  OR /apache_root/example.com/www   OR /apache_root/example.com      (any one of these is fine. But I don't want to use redirect for the sake of efficiency).</p>
  
  <p>3) <a href="http://abc.example.com" rel="nofollow">http://abc.example.com</a>   should be served by   /apache_root/example.com/abc (Basically, it should be directory inside /apache_root/example.com)</p>
  
  <p>Now comes the tricky part::</p>
  
  <p>All of the above can be achieved using the directory name Interpolation methods listed here: 
  <a href="http://httpd.apache.org/docs/2.0/mod/mod_vhost_alias.html#interpol" rel="nofollow">http://httpd.apache.org/docs/2.0/mod/mod_vhost_alias.html#interpol</a></p>
  
  <p>BUT::</p>
  
  <p>How to take care of the fact that example.com  can actually even be example.co.in ??</p>
  
  <p>(For base directory, if I use %2+ on example.co.in, it will give me co.in but I want example.co.in.  %1+ on <a href="http://abc.example.com" rel="nofollow">http://abc.example.com</a>,  will give me abc.example.com as base directory  instead of example.com which I want).</p>
  
  <p>Basically, I want a rule that will work consistently for:
  1)  www.abc.example.com<br>
  2) abc.example.com
  3) www.abc.example.co.in
  4) abc.example.co.in</p>
  
  <p>(Note: Apparently, the maximum levels in domain name is 127 <a href="http://en.kioskea.net/contents/internet/dns.php3" rel="nofollow">http://en.kioskea.net/contents/internet/dns.php3</a>.  That means 0.1.2.3.4.example.com is pretty much possible).</p>
  
  <p>cheers,</p>
  
  <p>JP</p>