 <p>First of all you need to create a catch all subdomain which will send all requests to your single VirtualHost:</p> <pre><code>ServerAlias *.website.com </code></pre> <p>Then you can either:</p> <ol> <li>Inspect the HTTP host at the application level and do whatever needs to be done (either serve content from the virtual subdomain, or do a 301 redirect to the www.</li> <li>Use a single mod_rewrite rule to rewrite the URL as you initially suggested.</li> </ol>