Q:

Enable DirectorySlash without showing query

If I have this code in my .htaccess in the root of my site:
RewriteCond %{REQUEST_URI} ^/foo/bar/
RewriteRule ^foo/bar(.*)$ http://example.org/foo/?file=$1 [P,QSA]

And have this file structure:
foo
 +-- index.php
 +-- bar
      +-- qaz
           +-- file.txt

And I request the page http://example.org/foo/bar/qaz/ it will redirect on the server to http://example.org/foo/?file=/qaz/.
However if I request the page http://example.org/foo/bar/qaz it will redirect to http://example.org/foo/?file=/qaz, however it will display http://example.org/foo/bar/qaz/?file=/qaz in the browser.
How do I enable the DirectorySlash, but still hide the query from the user?

A:

DirectorySlash only does this if the directory '/foo/bar/qaz' exists.
DirectorySlash doesn't respect rewriteBase. You could disable it and do it yourself with this:
RewriteCond %{DOCUMENT_ROOT}/$1 -d
RewriteRule ^(.*[^/])$ $1/ [R,L]

