title: Apache rewrite based on subdomain
body: <p>I'm trying to redirect requests for a wildcard domain to a sub-directory.<br />
  ie. <code>something.blah.example.com</code> --&gt; <code>blah.example.com/something</code></p>
  <p>I don't know how to get the subdomain name to use in the rewrite rule.</p>
  <p><strong>Final Solution:</strong></p>
  <pre><code>RewriteCond %{HTTP_HOST} !^blah\.example\.com
  RewriteCond %{HTTP_HOST} ^([^.]+)
  RewriteRule ^(.*) /%1/$1 [L]
  </code></pre>
  <p>Or as pointed out by pilif</p>
  <pre><code>RewriteCond %{HTTP_HOST} ^([^.]+)\.blah\.example\.com$
  </code></pre>