title: how to specify only one directory for an .htaccess rewrite rule?
body: <p>i had a rewrite rule working fine where any pages in the format <code>site.com/dir/page1.php</code> were translated into the format <code>site.com/page1</code>.  i achieved that with:</p>
  
  <pre><code># 1. turn on the rewriting engine
  RewriteEngine On
  
  # 2. remove the www prefix
  RewriteCond %{HTTP_HOST} ^www\.site\.com [NC] 
  RewriteRule ^(.*)$ http://site.com/$1 [L,R=301]
  
  # 3.  send all non-secure pages to secure pages
  RewriteCond %{HTTPS} off
  RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
  
  # 4. if 404 not found error, go to homepage
  ErrorDocument 404 /index.php
  
  # 5. if url received with trailing slash (e.g. http://domain/test/) then go to correct page (e.g. http://domain/pages/test.php)
  RewriteRule ^([^.]+)/$ includes/$1.php
  
  # 6. if url received WITHOUT trailing slash (e.g. http://domain/test) then go to correct page (e.g. http://domain/pages/test.php)
  RewriteRule ^([^.]+)$ includes/$1.php
  </code></pre>
  
  <p>i have now set up a blog at <code>site.com/blog/</code> and when i try and visit the blog it is displaying the home page (ie a 404 error).  </p>
  
  <p>i <em>think</em> the error is at part #5 and #6 and that somehow i need to specify that the rewrite rule is specifically only for the 'includes' directory?  but i could be wrong, any help appreciated, thank you!  </p>
  
  <p><strong>update:</strong></p>
  
  <p>i tried the solution to ignore the 'blog' directory here:</p>
  
  <p><a href="https://stackoverflow.com/questions/8525174/how-to-configure-htaccess-file-for-rewrite-rules-to-get-rid-of-extensions-trai?rq=1">How to configure .htaccess file for rewrite rules to get rid of extensions, trailing slashes, www?</a></p>
  
  <pre><code>#skip wordpress site which starts with blog
  RewriteCond %{REQUEST_URI} !^/blog [NC]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^([^\.]+)$ $1.php [NC,L]
  </code></pre>
  
  <p>but that didn't work for me unfortunately.  </p>