title: How to allow only logged in user to access files in a folder on linux server
body: <p>I created <strong>.htaccess file</strong> and place this piece of code in it :</p>
  
  <pre><code>Order Deny,Allow
  Deny from all
  </code></pre>
  
  <p>Here is my <strong>php code</strong> which is working fine on my windows machine with WAMP SERVER on it :</p>
  
  <pre><code>    $path = $data['path']; // complete path to file
  
  if (is_user_logged_in()) {
      //return $path;
      if (file_exists($path)) {
          header('Cache-Control: public');
          header('Content-Description: File Transfer');
          header('Content-Type: application/pdf');
          header('Content-Transfer-Encoding: binary');
          readfile($path);
      }
  } else {
      return 'Welcome, visitor!';
  } 
  </code></pre>
  
  <p>But when I run it on server, it didn't work at all. There is a locked folder, in which I have placed <code>.htaccess</code> file. And under locked folder there are many subfolders which I want to limit access to only logged in users.</p>