title: what is the best way to prevent certain directories of a web site from being directly accessed?
body: <p>Which is the best way to prevent certain directories of a web site from being directly accessed?</p>
  
  <p>1- Creating and placing a <code>.htaccess</code> file in each directory we want to protect and place the next line in it:</p>
  
  <pre><code>Deny from all
  </code></pre>
  
  <p>2- Creating and placing a <code>index.php</code> file in each directory we want to protect and place only the next line of code in it (which will redirect to homepage of the website):</p>
  
  <pre><code>&lt;?php header("Location: http://" . $_SERVER['HTTP_HOST']); ?&gt;
  </code></pre>
  
  <p>3- Something else (what is it?)</p>