title: Setup Dynamic Virtual Host (Apache2 on Ubuntu)
body: <p>I want to set up a single virtual host that can dynamically handle all requests based on the hostname used to access it.  If %{HTTP_HOST} could be used in a DocumentRoot, this is probably exactly what I want:</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
      ServerAdmin me@example.com
  
      DocumentRoot /var/www/live/%{HTTP_HOST}/public
      &lt;Directory /&gt;
              Options FollowSymLinks
              AllowOverride None
      &lt;/Directory&gt;
      &lt;Directory /var/www/live/%{HTTP_HOST}/public&gt;
              Options Indexes FollowSymLinks MultiViews
              AllowOverride None
              Order allow,deny
              allow from all
      &lt;/Directory&gt;
  
      # Possible values include: debug, info, notice, warn, error, crit, alert, emerg.
      LogLevel warn
      ErrorLog /var/www/live/%{HTTP_HOST}/logs/error.log
      CustomLog /var/www/live/%{HTTP_HOST}/logs/access.log combined
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>...unfortunately, %{HTTP_HOST} is not allowed in the DocumentRoot (<code>Warning: DocumentRoot [/var/www/live/%{HTTP_HOST}/public] does not exist</code>).  How else can I achieve my goal?</p>
  
  <p><strong>Update:</strong>  I thought of pointing a catch-all vhost to a single directory and having a .htaccess use mod_rewrite to dynamically select the path but (honestly) I'm exhausted.  I'll try at it again in the morning, but in the meantime, if anyone has good ideas, I'd love to hear them!  Thank you!</p>