title: Apache - Deny access to all directories except public
body: <p>I am developing a tool and I'm stuck at this point: I want to define a set of rules for each directory, basically I want only 'Public' folder avaible, and to deny access to other folders.</p>
  
  <p>My directoy structure is</p>
  
  <pre><code>uapi(root)/
      Application
      Config
      Public/
           Index.php
      Storage
      .htaccess
  </code></pre>
  
  <p>and here is .htaccess file</p>
  
  <pre><code>&lt;Directory /Public&gt;
      Order Deny, Allow
      Allow from all
      &lt;IfModule mod_rewrite.c&gt;
          Options +FollowSymLinks
          RewriteEngine On
          RewriteCond %{REQUEST_FILENAME} !-f
          RewriteCond %{REQUEST_FILENAME} !-d
          RewriteRule ^(.*)$ Index.php/$1 [L]
      &lt;/IfModule&gt;
  &lt;/Directory&gt;
  
  &lt;Directory /Config&gt;
      Order Deny, Allow
      Deny from all
  &lt;/Directory&gt;
  
  &lt;Directory /Application&gt;
      Order Deny, Allow
      Deny from all
  &lt;/Directory&gt;
  
  &lt;Directory /Storage&gt;
      Order Deny, Allow
      Deny from all
  &lt;/Directory&gt;
  </code></pre>