title: mod_rewrite, subdomains and htaccess in CodeIgniter
body: <p>Right now i'm working on a webshop project in codeigniter.
  In the end there will be multiple webshops on subdomains, and a frontpage on the main domain.</p>
  
  <p>It's supposed to be all dynamic so that the webshops get their own subdomains.
  The shop information is in the database. Lets say I have a mysql table which contains info like this:</p>
  
  <ul>
  <li>webshop:       Bobs shop</li>
  <li>webshop_subdomain:   bobsshop</li>
  </ul>
  
  <p>And so on.</p>
  
  <p>Now in a .htaccess file I want to make a rewrite rule so that bobsshop.mydomain.com will be rewritten to mydomain.com/bobsshop/ since i'm working in Codeigniter with controllers.</p>
  
  <p>You should bear in mind that the index.php also has to be rewritten out and there should also be the possibility to make subpages like bobsshop.mydomain.com/contact/</p>
  
  <p>I will make a php script which will check if the subdomain exists in the database and if it doesn't exist then the visitor will see a 404.</p>
  
  <p>My DNS setup looks like this ATM:</p>
  
  <ul>
  <li>mydomain.com        xxx.xxx.xxx.xxx</li>
  <li>*.mydomain.com      xxx.xxx.xxx.xxx</li>
  </ul>
  
  <p>Where xxx.xxx.xxx.xxx is my server IP.</p>
  
  <p>I've really never worked with htaccess / mod_rewrite before.
  Can it be done? And are there anyone who can help me make this? </p>
  
  <p>Sorry for my English. I hope you understand what I'm trying to do.</p>
  
  <p>Thanks in advance</p>