title: Does Apache2 support virtual hosting of subdomains?
body: <p>Currently my Apache server is set up like so</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
   ServerName www.example.com
   ServerAlias example.com
   DocumentRoot /var/www
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>The problem is that everything below <code>/var/www</code> is accessible from everywhere else. If I have a web page <code>/var/www/john/bio.html</code>, then that web page could borrow scripts/pictures from <code>var/www/jane/</code></p>
  
  <p>I want to set up my Apache server like so</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
   ServerName www.example.com
   ServerAlias example.com
   DocumentRoot /var/www
  &lt;/VirtualHost&gt;
  
  &lt;VirtualHost *:80&gt;
   ServerName www.john.example.com
   ServerAlias john.example.com
   DocumentRoot /var/www/john
  &lt;/VirtualHost&gt;
  
  &lt;VirtualHost *:80&gt;
   ServerName www.jane.example.com
   ServerAlias jane.example.com
   DocumentRoot /var/www/jane
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>So all the files for user <code>john</code> go in the <code>/var/www/john/</code> folder, and likewise for user <code>jane</code>. Then, with symbolic links turned off (by default), and access only provided from <code>/var/www/user/</code> downwards (again by default), I don't have to worry about <code>john's</code> web page including scripts/images from <code>jane's</code> web page. </p>