title: apache mod rewrite with the_request
body: <p>I want to do the following with apache (mod rewrite).</p>
  
  <ol>
  <li><p>if the user requests <a href="http://hostname.tld/index.php/folder/subfolder" rel="nofollow">http://hostname.tld/index.php/folder/subfolder</a> i want it to redirect (with a R=301) to <a href="http://hostname.tld/folder/subfolder" rel="nofollow">http://hostname.tld/folder/subfolder</a>.</p></li>
  <li><p>if the user requests <a href="http://hostname.tld/folder/subfolder" rel="nofollow">http://hostname.tld/folder/subfolder</a> the request should internally be rewritten to index.php/folder/subfolder.</p></li>
  </ol>
  
  <p>To prevent an endless redirect the first rule should check for %{THE_REQUEST}. The problem here is that I am unable to append "folder/subfolder" with a regex. How should I do this?</p>
  
  <p>For the second rule I have this (and seems to work).</p>
  
  <pre><code>RewriteCond %{HTTP_HOST} hostname.tld [NC]
  RewriteRule ^(.*)$ index.php [QSA,L]
  </code></pre>
  
  <p>The first one is still a problem.</p>
  
  <p>I think the first one should be something like</p>
  
  <pre><code>RewriteCond %{THE_REQUEST} (.*)index.php(.*) [NC]
  RewriteRule /index.php/$ http://hostname.tld/$1 [R=301,QSA,L]
  </code></pre>
  
  <p>But that is not really it.</p>