title: .htaccess only allow access to index.php and a directory
body: <p>I am using </p>
  
  <pre><code>RewriteEngine On
  RewriteRule ^.*$ ./index.php
  </code></pre>
  
  <p>to redirect all my website traffic through index.php and let my php code get the request_uri and route each request accordingly.</p>
  
  <p>I want to restrict access to all other files/directories except one that will contain the js files, css files, images etc.</p>
  
  <p>I found that to do that I can use:</p>
  
  <pre><code>Order deny,allow
  Deny from all
  
  &lt;Files index.php&gt;
      Order Allow,Deny
      Allow from all
  &lt;/Files&gt;
  </code></pre>
  
  <p>and then have another .htaccess file inside the public directory to allow certain file types.</p>
  
  <p>When I navigate to localhost/mysite/index.php it works fine since the index.php file is accessible.</p>
  
  <p>But for any other url I get a 403, for example /mysite/home/ is forbidden even though I expected it to work normally.</p>
  
  <p>What can I do get the expected behavior?</p>
  
  <p>My full .htacces file is:</p>
  
  <pre><code>RewriteEngine On
  
  RewriteCond %{SCRIPT_FILENAME} !-d
  RewriteCond %{SCRIPT_FILENAME} !-f
  
  RewriteRule ^.*$ ./index.php
  
  
  Order deny,allow
  Deny from all
  
  &lt;Files index.php&gt;
      Order Allow,Deny
      Allow from all
  &lt;/Files&gt;
  </code></pre>
  
  <hr>
  
  <p>EDIT: The /public/.htaccess currently looks like this:</p>
  
  <pre><code>&lt;Files ~ "\.(xml|css|jpe?g|png|gif|js|pdf)$"&gt;
    Allow from all
  &lt;/Files&gt;
  </code></pre>