title: Rewrite calls to index.php in redirected subdomain within .htaccess
body: <p>I have two domains currently in my server, one for the main domain (<code>www.domain.com</code>) and the other one for the test domain (<code>test.domain.com</code>). Each domain points to a folder containing a Joomla installation and within each folder there is the stardard <code>.htaccess</code> file that comes with the installation.</p>
  
  <p>The main domain works fine but the test domain does not quite work as expected. If I browse to <code>test.domain.com</code> I can see the Home page correctly but if I browse anywhere else (i.e. <code>test.domain.com/products.html</code>) I get a 500 error. However, if I append <code>index.php</code> after the subdomain it works as expected (i.e. <code>test.domain.com/index.php/products.html</code>).</p>
  
  <p>This is the <code>.htaccess</code> file in <code>/public_html</code> folder:</p>
  
  <pre><code>Options +FollowSymLinks
  
  RewriteEngine On
  RewriteBase /
  
  # pointing www.domain.com to live
  RewriteCond %{HTTP_HOST} !test.domain.com
  ReWriteCond %{HTTP_HOST} www.domain.com
  ReWriteCond %{REQUEST_URI} !^/live/
  ReWriteRule ^(.*)$ live/$1 [L]
  
  # pointing test.domain.com to test
  ReWriteCond %{HTTP_HOST} test.domain.com
  ReWriteCond %{REQUEST_URI} !^/test/
  ReWriteRule ^(.*)$ test/$1 [L]
  
  # Add a trailing slash to directories
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !(\.)
  RewriteCond %{REQUEST_URI} !(.*)/$
  RewriteRule ([^/]+)$ $1/ [L]
  
  # Rewrite any calls to /* to the index.php file
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)/$ index.php/$1 [L]
  </code></pre>
  
  <p>Here is the folder structure in the server:</p>
  
  <pre><code>/public_html
      |
      |--/live             &lt;-- www.domain.com
      |     |
      |     |--.htaccess   &lt;-- joomla standard .htaccess
      |
      |--/test             &lt;-- test.domain.com
      |     |
      |     |--.htaccess   &lt;-- joomla standard .htaccess
      |
      |--.htaccess
  </code></pre>
  
  <p>The <code>.htaccess</code> files in the <code>live</code> and <code>test</code> folders have <code>RewriteBase /live</code> and <code>RewriteBase /test</code> respectively. </p>
  
  <p>I have found several questions regarding subdomain redirection here in stackoverflow and in many other sites but none of them solve this specific issue. Does anyone know what I am missing?</p>
  
  <p>Thanks.</p>