title: Use .htaccess to prevent root directory from public access
body: <p>I don't know such thing is possible or not practically, but let's give it a try. In past (more than three years ago), I came to know about solution like this (don't know exactly how it is), in one MVC tutorial.</p>
  
  <p><strong>Directory structure</strong></p>
  
  <ul>
  <li>WebRoot/
  <ul>
  <li>includes/</li>
  <li>config/</li>
  <li>public/
  <ul>
  <li>images/</li>
  <li>js/</li>
  <li>css/</li>
  <li>index.php</li>
  </ul></li>
  <li>init.php</li>
  </ul></li>
  </ul>
  
  <p><strong>What I Want To Do Is</strong></p>
  
  <p>When user access <code>http://www.mysite.com/a/b/c/</code>, redirect all requests to <code>/public/index.php</code> page. i.e., all requests to website will go through <code>/public/index.php</code> page, except <code>images/</code>, <code>js/</code> and <code>css/</code> directories, which are in <code>public/</code>.</p>
  
  <p>Also, <code>http://www.mysite.com/includes/</code> will redirect to <code>index.php</code> page, and get <code>includes/</code> as <code>$query</code>.</p>
  
  <p><strong>Index.php page</strong></p>
  
  <pre><code>&lt;?php
  
  // get init file from webroot directory, which will load all required php files.
  define ('ROOT', dirname(dirname(__FILE__)));
  require_once (ROOT . 'init.php');
  
  
  // get query from url (here, $query = "a/b/c/")
  if(isset($_GET['q'])) {
      $query = $_GET['q'];
  }
  
  // insert images, css etc. resource
  echo "&lt;img src='http://www.mysite.com/images/foo.jpg' /&gt;";
  echo "&lt;script src='http://www.mysite.com/js/bar.js'&gt;&lt;/script&gt;";
  
  ?&gt;
  </code></pre>
  
  <p>This will be useful for them who are using web-hosting, which doesn't provide one step up directory access to webroot.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>OK, I found the site from where I got this concept. See two .htaccess files used in root directory and public directory. <a href="http://anantgarg.com/2009/03/13/write-your-own-php-mvc-framework-part-1/" rel="nofollow">Link to MVC tutorial</a></p>