title: htaccess - Rewriting requests for subdomain to a folder, with query string
body: <p>I'm trying to get a subdomain rewrite working using an Apache htaccess file and need some help please.</p>
  
  <p>I am trying to get requests for <em>http://<strong>xyz</strong>.example.com</em> internally handled <em>as if</em> the user had requested <em>http://example.com/<strong>xyz</strong></em> so the user does not see this URL in their address bar - they see the subdomain version.</p>
  
  <p>This is slightly complicated by the fact that anything following this <em>also</em> needs to be passed too, for example if the user requests <em>http://<strong>xyz</strong>.example.com/test/word/?x=123</em> then this needs to be handled by the server as if they had visited <em>http://example.com/<strong>xyz</strong>/test/word/?x=123</em>.</p>
  
  <p>The site is running on the Code Igniter framework, which had its own htaccess rules too, but I guess this rewrite would be done first before those kick in.</p>
  
  <p>Any help would be greatly appreciated!</p>