title: Apache rewrite rule to redirect all request to subdirectory containing another .htaccess and rewrite rules
body: <p>I have public and private projects on my webserver. I put everything what is public into the webserver root, and I have a <code>private</code> folder there which I can only reach from local network (set by .htaccess in there).</p>
  
  <p>I want to simply put every private projects in the <code>private</code> folder and handle the requests automatically, but want the URLs look like they are served from webroot.<br>
  For example if there is <code>private/project1</code> I want to use the URL <a href="http://example.com/project1">http://example.com/project1</a> to serve that folder and don't want to change the URL.</p>
  
  <p>This simple rewrite:</p>
  
  <pre><code>RewriteEngine On
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ private/$1           
  </code></pre>
  
  <p>works, but when I have a <code>private/project2</code> with another <code>.htaccess</code>:</p>
  
  <pre><code>Options +FollowSymLinks
  &lt;IfModule mod_rewrite.c&gt;
  RewriteEngine On
  RewriteBase /project2/
  
  &lt;Files .*&gt;
         Order Deny,Allow
         Deny From All
  &lt;/Files&gt;
  
  # Allow asset folders through
  RewriteRule ^(assets/.+) - [L]
  
  # Protect files from being viewed
  RewriteRule ^(uploads.+) - [F,L]
  
  
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  
  RewriteRule ^(.*)$ index.php/$1 [L]
  
  &lt;/IfModule&gt;
  Options -Indexes
  </code></pre>
  
  <p>then the static content will appear, but the links are broken.
  What should I modify to work ?</p>
  
  <p>Also if I have a <code>private/project3</code> and browse to <code>http://example.com/project3/</code> there is no problem, but when I browse to <code>http://example.com/project3</code> (without the trailing /) the URL will be visible as <code>http://example.com/private/project3/</code> in the browser. Why ? How can I avoid that ?</p>