title: Change DocumentRoot in Apache depending on URL path
body: <p>I'm redoing my API. Fortunately, its versioned. Yay! But what's the best way to handle the new code.</p>
  
  <p>Basically; I have <code>api.example.com/v1/method</code> etc. My site runs on apache, and <code>api.example.com</code> points to <code>/var/www/html/api.example.com</code></p>
  
  <p>For the new API, I will be using a completely different framework and codebase etc, so I don't want to mix up the files.</p>
  
  <p>Ideally, what I want is <code>api.example.com/v1/</code> to point to <code>/var/www/html/api-v1.example.com</code> and <code>api.example.com/v2/</code> to point to <code>/var/www/html/api-v2.example.com</code>.</p>
  
  <p>[Edited, I originally said subdirectories which I think is confusing, but really I think I want them as completely separate sites]</p>
  
  <p>Is this possible using Apache?</p>
  
  <p>Additional question: if instead of using <code>/v1/</code> <code>/v2/</code> etc, I versioned my API by using an Accept header like:</p>
  
  <pre><code>Accept: application/vnd.api-example-com-v2+json
  </code></pre>
  
  <p>how would I map that to a different directory?</p>