title: .htaccess: rewrite .htm urls internally to .php, but also redirect .php urls to .htm
body: <p>I have a php site. For all of the page links I use foo.htm, and internally rewrite this to foo.php with .htaccess:</p>
  
  <pre><code>RewriteRule ^(.*)\.htm$ $1.php [NC,L]
  </code></pre>
  
  <p>This works great - however, it still allows you to use the foo.php url. I would like to 301 redirect foo.php to foo.htm to prevent any old foo.php search engine results from hanging around and rewrite the foo.htm url internally to foo.php</p>
  
  <p>I can't figure out how to do this without creating a loop.</p>