title: Apache Rewrite htaccess in subdir
body: <p>let me get to the point.</p>
  
  <p>I have a php project that has this structure</p>
  
  <pre><code>ROOT
  .htaccess
  --api/
  ----public/
  ------index.php
  ------test.html
  --backoffice/
  </code></pre>
  
  <p>And what I want is to use the index.php of api/public to get it working like </p>
  
  <pre><code>domain.com/api/index.php 
  </code></pre>
  
  <p>instead of </p>
  
  <pre><code>domain.com/api/public/index.php 
  </code></pre>
  
  <p>I've been trying with no success the rewritebase or rewriterules of .htaccess, I'm missing something? putting the .htaccess in the wrong directory? I have to use multiple .htaccess?</p>
  
  <p><strong>UPDATED</strong>:  So I got my two .htaccess files, by now I'm able to access with the url domain.com/api/index.php but it throws 401 , it's something... on the other hand I can access to the file test.html located under /api/public with the current url domain.com/api/test.html </p>
  
  <p>Here are the .htaccess<br>
  <strong>domain.com/api/ .htaccess file</strong> </p>
  
  <pre><code>RewriteEngine On
  RewriteBase /api/public/
  RewriteCond %{REQUEST_URI} !^/api/public/
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ /api/public/$1
  </code></pre>
  
  <p><strong>domain.com/api/public/ .htaccess file</strong> </p>
  
  <pre><code>RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^ index.php [QSA,L]
  </code></pre>