title: Apache mod_rewrite: rewrite ^(.*)\.html$ to $1.php and forbid direct access to ^(.*)\.php$
body: <p>My intent is to rewrite urls ending in .html to .php (not actually all of them, but that shouldn't really matter with regard to this question). I'd also like to disallow urls ending in .php (so that the user can access every page only using urls with .html extension).</p>
  
  <p>I'm using these rules inside .htaccess:</p>
  
  <pre><code>RewriteRule ^(.*)\.php$ $1.html [R,L]
  RewriteRule ^(.*)\.html$ $1.php [L]
  </code></pre>
  
  <p>However, this causes a redirection loop. I suppose this happens because the rewritten .html to .php url is fed back to mod_rewrite and causes the first rule to trigger.</p>
  
  <p>Can anyone help me?</p>