title: Wordpress protect file if not logged in
body: <p>I've in the past protected PDFS when a user is not logged in using the following code : </p>
  
  <pre><code>RewriteCond %{REQUEST_FILENAME} ^.*(pdf)$
   RewriteCond %{HTTP_COOKIE} !^.*wordpress_logged_in.*$ [NC]
   RewriteRule . - [R=403,L]
  </code></pre>
  
  <p>For some reason it quit working on me. Research has shown that maybe wordpress-logged_in is no longer relevant as it was a hacking hole. Is there an alternative solution for protecting PDF documents if a user is not logged in?</p>
  
  <p>These pdfs are not embedded on a page rather "hot linked" if you will. I'm not looking for a bloated plugin. Just a solution to protect PDF's specifically.</p>
  
  <p><strong>Edit:</strong> </p>
  
  <p>Below is my full htaccess.</p>
  
  <pre><code># BEGIN WordPress
  &lt;IfModule mod_rewrite.c&gt;
  RewriteEngine On
  RewriteBase /new/
  RewriteRule ^index\.php$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /new/index.php [L]
  &lt;/IfModule&gt;
  
  # END WordPress
  
  
  RewriteCond %{REQUEST_FILENAME} ^.*(pdf)$
  RewriteRule ^(.*)$ /wp-content/download-protect.php?file=$1 [L]
  
  # disable directory browsing in WordPress
   Options -Indexes
  
  # protect wp-config.php
   &lt;files wp-config.php&gt;
  order allow,deny
  deny from all
  &lt;/files&gt;
  
  #  Protect .htaccess
  &lt;files ~ "^.*\.([Hh][Tt][Aa])"&gt;
  order allow,deny
  deny from all
  satisfy all
  &lt;/files&gt;
  </code></pre>