title: .htaccess rewrite /foo/bar/ to /foo/bar.php
body: <p>I'm looking to set rules in my .htaccess file so that all files with a .php extension can be accessed by replacing the extension with just a slash (<code>/foo/bar/</code> would silently load <code>/foo/bar.php</code>). Previously, I found <a href="https://stackoverflow.com/questions/9608413/htaccess-rewrite-all-php-files">this</a>, which is kind of what I'm looking for, except it only changes <code>/foo/bar.php</code> to <code>/foo/bar</code> (notice there is no end slash). </p>
  
  <p>I'm almost a completely newbie when it comes to htaccess, and about 30 minutes of tweaking with the code from the previous link produced nothing by a ton of <code>500 internal server error</code>s. I'm sure it's such a simple fix, but neither Google nor trial and error have yet to bring me any results.</p>
  
  <p>Could anyone take a look at the code from the aforementioned post (copied below) and change it so that <code>/foo/bar/</code> will rewrite to <code>/foo/bar.php</code>?</p>
  
  <pre><code>Options +FollowSymLinks -MultiViews
  # Turn mod_rewrite on
  RewriteEngine On
  RewriteBase /
  
  ## hide .php extension
  # To externally redirect /dir/foo.php to /dir/foo
  RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
  RewriteRule ^ %1 [R,L,NC]
  
  ## To internally redirect /dir/foo to /dir/foo.php
  RewriteCond %{REQUEST_FILENAME}.php -f
  RewriteRule ^ %{REQUEST_URI}.php [L]
  </code></pre>
  
  <p>Many thanks!</p>