title: rewrite rule deppend form request domain
body: <p>I have one repository for 2 instances code: <code>domain.com</code> and <code>api.domain.com</code>.</p>
  
  <p>What should the rules look like for:</p>
  
  <p>Serving another <code>robots.txt</code> file for the <code>api.doamin.com</code> domain</p>
  
  <p>For the domain <code>api.domain.com</code>, blocking of traffic other than to <code>api.domain.com/api/</code> (<code>/api/</code> allowed, <code>/resources/</code>, ... disallowed or redirected to main domain)</p>
  
  <p>Edit 1: (.htaccess after suggested changes)</p>
  
  <pre><code># Turn on URL rewriting
  RewriteEngine On
  
  # Installation directory
  RewriteBase /
  
  Redirect "/f/" "/assets/"
  
  # Protect hidden files from being viewed
  &lt;Files .*&gt;
      Order Deny,Allow
      Deny From All
  &lt;/Files&gt;
  
  RewriteCond %{HTTP_HOST} =api.domain.com
  RewriteRule !^api/ [F,NC]
  
  RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
  RewriteRule \.(gif|jpe?g|png|bmp)$ index.php/image404/index/?r=%{REQUEST_URI} [NC,L]
  
  # Protect application and system files from being viewed
  RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]
  
  # Allow any files or directories that exist to be displayed directly
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  
  # Rewrite all other URLs to index.php/URL
  RewriteRule .* index.php/$0 [PT]
  </code></pre>