title: htaccess deny all at root, allow access matching url after a rewrite
body: <p>I am trying to secure an application on a shared hosting where I can only write .htaccess files. Everything is in the public folder www.</p>
  
  <p>I want to restrict access to only one subdirectory while forbidding access to all others. I also want the root url <code>http://&lt;domain&gt;/</code> to show the content of that allowed directory.</p>
  
  <pre><code>www/
  ├── ...
  ├── private/
  ├── public/ (I want to allow access to this one only)
  └── .htaccess
  </code></pre>
  
  <p>So far, my <code>.htaccess</code> looks like this:</p>
  
  <pre><code>RewriteEngine on
  RewriteRule ^(.*)$ /public/$1 [R]
  
  Order allow,deny
  Deny from all
  
  &lt;Files "/public/*"&gt;
      Allow from all
  &lt;/Files&gt;
  </code></pre>
  
  <p>With this, if I go visit <code>http://&lt;domain&gt;/public</code> everything works fine. But if I go to <code>http://&lt;domain&gt;/</code> I get a 403 access denied.</p>
  
  <p>How can I redirect the root URL to show the content of my public folder, while still denying access to everything else at the root?</p>