title: .htaccess rewrite: subdomain as GET var and path as GET var
body: <p>Desired result:</p>
  
  <pre><code>http://example.com/                 -&gt; index.php
  http://www.example.com/             -&gt; index.php
  http://hello.example.com/           -&gt; index.php?subdomain=hello
  http://whatever.example.com/        -&gt; index.php?subdomain=whatever
  http://example.com/world            -&gt; index.php?path=world
  http://example.com/world/test       -&gt; index.php?path=world/test
  http://hello.example.com/world/test -&gt; index.php?subdomain=hello&amp;path=world/test
  </code></pre>
  
  <p>With the .htaccess I have right now, I can achieve one or the other re-mapping, but not both at the same time.</p>
  
  <pre><code>RewriteEngine On
  
  # Parse the subdomain as a variable we can access in PHP, and
  # run the main index.php script
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{HTTP_HOST}        !^www
  RewriteCond %{HTTP_HOST}         ^([^\.]+)\.([^\.]+)\.([^\.]+)$
  RewriteRule ^.*$ index.php?subdomain=%1
  
  # Map all requests to the 'path' get variable in index.php
  RewriteBase /
  RewriteRule ^index\.php$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ /index.php?path=$1 [L] 
  </code></pre>
  
  <p>I'm having a hard time combining the two...any pointers, please?</p>
  
  <p><strong>EDIT</strong><br>
  The unwanted behavior I'm experiencing now is that if I have a subdomain and a path after .com/, only the subdomain will be passed through, ie:</p>
  
  <pre><code>http://hello.example.com/world-&gt; index.php?subdomain=hello
  </code></pre>