title: .htaccess conditional rewrite
body: <p>I'm trying to create an conditional Rewrite Rule using an .htaccess file and Apache.</p>
  
  <p>Basically what I need is that the Apache would check if the requested file exists in a sub folder, case in which Apache would serve this existing file, or, if the file does not exist, Apache would load the index.php file.</p>
  
  <p>The folder structure I'm using is:</p>
  
  <pre><code>- /gallery
    - /cache
    - index.php
    - .htaccess
  </code></pre>
  
  <p>also, the .htaccess I have now is</p>
  
  <pre><code>RewriteEngine on
  RewriteCond %{REQUEST_FILENAME} -f
  RewriteRule ^(.+) - [PT,L]
  RewriteRule ^(.*)$ index.php/$1 [L]
  </code></pre>
  
  <p>however, this works only if the file I'm trying to look for is in the /gallery folder, however I need to look if the file exists in the /cache folder instead.</p>
  
  <p>Does anyone know how to modify this rules in order to achieve that?</p>
  
  <p>Thank you in advance,</p>
  
  <p>titel</p>