title: .htaccess only allow access and redirect to root index.php for only one directory
body: <p>I'm getting some troubles with htaccess in my new php project . I couldn't find any solutions so I ask here , hope someone will help me out.</p>
  
  <p>1 . What I need :</p>
  
  <p>On root , urls pointing to existing files and folders are not accessible , except     /Public/ and all its folders and files ( only /Public/ is allowed to access ) . Urls pointing to files and folders which are not existings will be redirected to <strong>root index.php</strong>. /Public/ is redirected to <strong>root index.php</strong> too , folders and files inside it are not ( direct access ).</p>
  
  <p>2 . What I have tried and are not working :</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
   RewriteEngine On
   RewriteBase /
   RewriteRule ^index\.php$ - [L]
   RewriteCond %{REQUEST_URI} !^/Public
   RewriteCond %{REQUEST_FILENAME} !^index\.php$
   RewriteCond %{REQUEST_FILENAME} -f
   RewriteCond %{REQUEST_FILENAME} -d
   RewriteRule . - [F,L,NC]
   RewriteBase /Public/
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule . /index.php [L,QSA]
  &lt;/IfModule&gt;
  ------------------------------------
  &lt;IfModule mod_rewrite.c&gt;
   RewriteEngine On
   RewriteBase /
   RewriteRule ^index\.php$ - [L]
   RewriteCond %{REQUEST_URI} !^/Public
   RewriteRule . - [F,L,NC]
   RewriteBase /Public/
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule . /index.php [L,QSA]
  &lt;/IfModule&gt;
  ------------------------------------
  &lt;IfModule mod_rewrite.c&gt;
   RewriteEngine On
   RewriteBase /
   RewriteRule ^index\.php$ - [L]
   RewriteCond %{REQUEST_FILENAME} -f
   RewriteCond %{REQUEST_FILENAME} -d
   RewriteRule . - [F,L,NC]
   RewriteBase /Public/
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule . /index.php [L,QSA]
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>Thank you in advance :)</p>