title: Extensionless URL trailing slash redirect
body: <p>I tested the code below on several Dreamhost domains, and it works, except on newer domains added circa 2012</p>
  <pre><code>RewriteEngine on
  
  #unless directory, remove trailing slash
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)/$ $1 [R=301,L]
  
  #redirect external .php requests to extensionless url
  RewriteCond %{THE_REQUEST} ^(.*)\.php([#?][^\ ]*)?\ HTTP/
  RewriteRule ^(.*)\.php$ $1 [R=301,L]
  
  #resolve .php file for extensionless php urls
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME}\.php -f
  RewriteRule ^(.*)$ $1.php [L]
  </code></pre>
  <h3>example that works</h3>
  <p><a href="http://ryanve.com/resources/lame/" rel="nofollow noreferrer">ryanve.com/resources/lame/</a> and <a href="http://ryanve.com/resources/lame.php" rel="nofollow noreferrer">ryanve.com/resources/lame.php</a> both redirect to <a href="http://ryanve.com/resources/lame" rel="nofollow noreferrer">ryanve.com/resources/lame</a> and the actual file that is served is lame.php</p>
  <h3>broken example</h3>
  <p><a href="http://airve.com/test/file" rel="nofollow noreferrer">airve.com/test/file</a> properly serves file.php but the redirects <a href="http://airve.com/test/file/" rel="nofollow noreferrer">airve.com/test/file/</a> and <a href="http://airve.com/test/file.php" rel="nofollow noreferrer">airve.com/test/file.php</a> don't work. Try them and you'll see they seem to be spitting out the internal absolute path. The same thing occurred when I tried each of the redirects independently and when I tried the basic redirect below.</p>
  <pre><code>Redirect 301 /test/file/ /test/file
  </code></pre>
  <p>There is nothing else in .htaccess. Any idea on what the issue is?</p>