title: .htaccess Conflict: How can I remove .php AND rewrite URLs?
body: <p>Here's my situation: I have a directory which I need to rewrite URLs in, so that <code>?page=hello</code> can be accessed at either <code>/hello</code> or <code>/hello/</code>. I then have a sub-directory which needs <code>.php</code> extensions to be internally appended, so <code>/subdir/example.php</code> can be accessed at <code>/subdir/example</code> and <code>/subdir/example/</code>.</p>
  <p>I developed the two parts of the site independently, and I'm now having trouble getting htaccess to meet both requirements.</p>
  <p>My current <code>.htaccess</code> file is:</p>
  <pre><code>RewriteEngine On
  
  # The root directory bit...
  Redirect 301 /home /
  RewriteEngine On
  RewriteCond %{REQUEST_URI} !/subdir
  RewriteRule ^([A-Za-z0-9-_/]+)/?$ index.php?page=$1 [L]
  
  # Remove .php
  RewriteEngine On
  RewriteRule ^(.+)\.php$ /$1 [R,L]
  RewriteCond %{REQUEST_FILENAME}.php -f
  RewriteRule ^(.*?)/?$ /$1.php [NC,END]
  </code></pre>
  <p>The rules work perfectly independently, ie if I remove the other one, but, together, does append.php but the rewrite rule fails.</p>
  <p>I've tried making two separate htaccess files, one for the subdir and one for the root dir, with the appropriate rule (nice URL rule for root dir and remove .php for subdir), but this just means that appending .php no longer works.</p>
  <p>Does anyone have any solutions to this?- or any resources to point me in the right direction? I'm currently in a hole of PHP and Apache documentation!</p>