title: mod_rewrite redirect loop / breaks my site
body: <p><strong>What I want:</strong></p>
  
  <ul>
  <li><code>/foo.php</code> display <code>/foo</code> in url bar</li>
  <li><code>/foo</code> redirect to <code>/foo.php</code></li>
  <li>Both must view <code>/foo.php</code></li>
  <li>Must work with <code>/showthread.php?id=00</code> (<code>/showthread?id=00</code>) and such </li>
  </ul>
  
  <p>I constantly get a redirect loop even if I use [L] everywhere.
  I tried these:</p>
  
  <pre><code>(1)
  RewriteRule ^/forums$ forums.php [R]
  RewriteRule ^/forums\.php$ forums [PT]
  (2)
  RewriteRule ^forums\.php/?$ forums [L,R=301]
  RewriteRule ^forums/?$ forums.php
  (3)
  RewriteRule ^forums/?$ forums.php [L,R=301]
  (4)
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^/?([a-z/]+).php$ $1 [R,L]
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule (.*) $1.php [L]
  </code></pre>
  
  <p>Each of the above work for individually <code>foo.php</code> to <code>foo</code> or <code>foo</code> to <code>foo.php</code> but infinite loop on both.</p>
  
  <p>I also tried this:</p>
  
  <pre><code>## don't touch /forum URIs
  # RewriteRule ^forums/ - [L,NC]
  
  ## hide .php extension snippet
  
  # To externally redirect /dir/foo.php to /dir/foo
  # RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
  # RewriteRule ^ %1 [QSA,R,L]
  
  # To internally forward /dir/foo to /dir/foo.php
  # RewriteCond %{REQUEST_FILENAME} !-d
  # RewriteCond %{REQUEST_FILENAME}.php -f
  # RewriteRule ^(.*?)/?$ $1.php [QSA,L]
  </code></pre>
  
  <p>Which works as expected but breaks a lot of site features for some reason. (search bar does not work, forums don't work, login doesn't work)</p>
  
  <p>I need <code>foo.php</code> to still work because MyBB uses it.</p>