title: How do i create virtual subdomain using htaccess?
body: <p>I would like to create virtual sub domains for clients who will have websites with us but the websites will be served from a single url in reality for example;</p>
  
  <hr>
  
  <p><strong><em>main site:</em></strong></p>
  
  <p>domain.com/post/20/Posttitle
  <br>
  domain.com/index.php?r=post/20/Posttitle</p>
  
  <p><strong><em>sub site:</em></strong></p>
  
  <p>mysub.domain.com
  <br>
  domain.com/index.php?s=mysub</p>
  
  <p>OR</p>
  
  <p>mysub.domain.com/post/20/Posttitle
  <br>
  domain.com/index.php?s=mysub&amp;r=post/20/Posttitle</p>
  
  <p>OR</p>
  
  <p>mysub.domain.com/Cat/2/cattitle
  <br>
  domain.com/index.php?s=mysub&amp;r=Cat/2/cattitle</p>
  
  <p>OR</p>
  
  <p>mysub.domain.com/{OrderURL}
  <br>
  domain.com/index.php?s=mysub&amp;r={OrderURL}</p>
  
  <p>....</p>
  
  <p>** In a general example: <strong>Blog system</strong></p>
  
  <hr>
  
  <p>How do i do this?</p>
  
  <p>Also my setup is with PHP{Something like the MVC} and cPanel / WHM server.
  <br>Note: The design on localhost</p>
  
  <p>Here is the htaccess code i have tried so far (does not work properly);</p>
  
  <pre><code>RewriteCond %{HTTP_HOST} ^(http://|https://)?(www\.)?(.*\.)?(.*)$
  RewriteRule (http://|https://)?(www\.)?(.*\.)?(.*)$ index.php?s=$3&amp;r=$4 [L,NC,QSA]
  
  RewriteRule ^(.*)$ index.php?r=$1 [L,NC,QSA]
  </code></pre>