title: .htaccess folder as parameter to root index.php
body: <p>What I need is any subfolder to be passed as a parameter to the root index.php
  This is the code and it actually works.</p>
  
  <pre><code>RewriteEngine On
  RewriteBase /
  RewriteCond %{SCRIPT_FILENAME} !-f
  RewriteCond %{SCRIPT_FILENAME} -d
  RewriteRule ^(.+?)(/[^/]*|)$ index.php?dir=$1/ [L,QSA]
  </code></pre>
  
  <p>There is a problem:</p>
  
  <p>When the url is like this (no end slash after 'projects'):<br>
  <code>http://example.com/projects</code></p>
  
  <p>the rewrite rule changes the link in the address bar and it looks like this:<br>
  <code>http://example.com/projects/?dir=projects/</code></p>
  
  <p>Is there a chance the url in the address bar always stays the same(no matter if there is an end slash or not) so the dir parameter is not visible to the user?</p>
  
  <p>I tried with multiple rules - the first one to add an end slash, and then the second rule to pass the directory as parameter, but with no luck so far.</p>
  
  <p>EDIT: so far thanks to w3d I managed to get it working. In the .htaccess just add: 
  DirectorySlash Off</p>