title: Avoiding directory listing after turning DirectorySlash Off
body: <p>My website file structure is as follows:</p>
  
  <pre><code>.htaccess (No:1)
  /application
  /library
  /public
      /static
      index.php
      .htaccess (No:2)
  </code></pre>
  
  <p><strong>.htaccess (No:1)</strong> contains:</p>
  
  <pre><code>DirectorySlash Off
  RewriteEngine On
  RewriteBase /
  
  RewriteCond %{REQUEST_FILENAME} -d 
  RewriteRule ^(.*[^/])$ $1/ #The step I tried to avoid directory Listing
  
  RewriteRule ^$ public/   
  RewriteRule ^(.*)$ public/$1  #Redirect everything to public folder
  </code></pre>
  
  <p><strong>.htaccess (No:2)</strong> contains:</p>
  
  <pre><code>RewriteEngine On
  RewriteBase /
  
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php
  RewriteRule ^$ index.php #rewrite everything (if not a file) to index.php
  </code></pre>
  
  <p>When requested url is "/public" or "/library" or /application"(Please note that <strong>DirectorySlash is Off</strong>), it shows the directory listing of the respective  folder. But when a trailing slash is added, everything works fine -> It gets rewritten to index.php and looks for the Controller.</p>
  
  <p>I tried to avoid the directing listing by placing this code on .htaccess (No:1),already specifed:</p>
  
  <pre><code>RewriteCond %{REQUEST_FILENAME} -d 
  RewriteRule ^(.*[^/])$ $1/
  </code></pre>
  
  <p>This fixed the problem of "directory listing" except for the public folder.</p>
  
  <p>What I want is to fix this problem of directory lisitng when "/public" is requested.I dont want to make use of methods like "deny from all" or "Options FollowSymlinks" to deny directory listing of public directory, but rewrite it to index.php</p>