title: .htaccess configuration for Slim PHP REST API on a subdomain?
body: <p>I currently have an api.php file built using the <a href="http://www.slimframework.com/" rel="nofollow">Slim Framework</a>. I'd like to use something like api.mydomain.com (or mydomain.com/api) to reference the API file and make calls using <a href="http://api.mydomain.com" rel="nofollow">http://api.mydomain.com</a> as the base url. The Slim documentation calls for the following to be added to your .htacess file:</p>
  
  <pre><code>RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^ index.php [QSA,L]
  </code></pre>
  
  <p>But if I'm correct, that returns the index.php file if the file requested doesn't exist. How best to setup a rewrite from api.mydomain.com or mydomain.com/api to the index.php? Everything we've found points to configuring this using .htaccess.</p>
  
  <p>We used the following rewrite rule, but this resulted in having slashes ('/') appended to all of our URLs, which also required us to reconfigure our routes in Slim as well. (Example: "/messages" became "/messages/" and "/threads?id=123" became "/threads/?id=123")</p>
  
  <pre><code>RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{HTTP_HOST} ^api\.mydomain\.com [NC]
  RewriteRule ^ api.php [QSA,L]
  </code></pre>