title: .htaccess rewrite subdomain to directory and keep subdomain in url
body: <p>I need to rewrite a subdomain to a subdirectory using .htaccess but keep the subdomain in the url like this:</p>
  
  <p>Visited url in browser: <code>sub1.domain.com</code></p>
  
  <p>Served url: <code>sub.domain.com/sub1/</code></p>
  
  <p>I tried the following</p>
  
  <pre><code>RewriteCond %{HTTP_HOST} ^subdomain.domain.com
  RewriteRule ^(.*)$ http://subdomain.domain.com/subdomain/$1 [L,NC,QSA]
  </code></pre>
  
  <p>but this leads to an endless loop. I know that it would be easier to do this by php but is there any  solution for this with using .htaccess? </p>