title: .htaccess, proper rewriting of directory and file with same name
body: <p>As of now my website has a few static pages, one of which is /portfolio. Among other things, my htaccess hides the .html extension.  I'd like to add a portfolio directory, but I do not want to move my existing portfolio page into the portfolio directory as the default index file.  My /portfolio page is one of my Google sitelinks and I am afraid if it is moved or if the url changes in someway, Google will consider it to be a brand new page.</p>
  
  <p>My problem is once I add the /portfolio/ directory, whenever I try to visit the original /portfolio page, a trailing slash is automatically added and it links to the directory itself.</p>
  
  <p>I've tried countless options, one being a rewrite of /portfolio/ to /portfolio, however this creates an infinite loop.  I also tried "DirectorySlash Off" but that only removed the trailing slash while being inside the directory, it didn't revert access to the original /portfolio page.</p>
  
  <p>Ultimately, I would like to keep my /portfolio page as-is, linking to pages inside the directory like so /portfolio/example and if either /portfolio or /portfolio/ is accessed it will result in showing the same page which is outside of the directory without Google thinking it is duplicate content.</p>
  
  <p>A similar question exists here:
  <a href="https://stackoverflow.com/questions/1237531/htaccess-rewriting-url-to-page-or-directory">.htaccess rewriting url to page or directory</a> though this still resulted in an infinite loop for me for some reason, I'm guess it has something to do with the hidden extensions.</p>
  
  <p>Here's my htaccess-</p>
  
  <pre>
  RewriteEngine On
  
  # HTML to PHP
  RemoveHandler .html .htm
  AddType application/x-httpd-php .htm .html
  
  # Hide extension
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME}\.html -f
  RewriteRule ^(.*)$ $1.html
  
  # Force WWW
  RewriteCond %{HTTP_HOST} ^mydomain\.net
  RewriteRule ^(.*)$ http://www.mydomain.net/$1 [R=301,L]
  
  # Blog Subdomain
  RewriteCond %{HTTP_HOST} ^blog.mydomain.net$
  RewriteRule ^(.*)$ http://www.mydomain.net/blog/$1 [R=301,L]
  </pre>
  
  <p>I know it's not a great idea having a directory with the same name as a static page, but I really would rather not alter the existing page and lose the Google sitelink, so a clean and proper way to handle this would be a help.</p>