title: mod_rewrite /foo to /index.php?id=foo AND /foo/foo2 to /index.php?id=foo/foo2
body: <p>I have a problem with mod_rewrite.</p>
  
  <p>I want to redirect those URIs in the title. I use the following rule</p>
  
  <pre><code>RewriteEngine on
  
  RewriteCond $1 !^(folders not to be redirected e.g. css|images)
  RewriteCond $1 !^(.*).(file extension e.g. png|css|txt|php)
  
  RewriteRule ^(.*)$ index.php?id=$1 [L]
  </code></pre>
  
  <p>It work only if I put all the resources in a folder, else it would tell me:</p>
  
  <pre><code>"/foo/index.php" not found.
  </code></pre>
  
  <p>So to solve that I put all the resources in the folder "www"</p>
  
  <p>But when I try to load the resources from a subfolder of e.g. "foo" it tells me:</p>
  
  <pre><code>The requested URL "/foo/foo2" was not found on this server.
  </code></pre>
  
  <p>How can I load resources from a subfolder like "/foo/foo2" or even "/foo/foo2/foo3"?</p>
  
  <p>And how can I solve the problem with the automatic search for index.php in a folder?</p>