title: How to write an htaccess rule for nginx to protect a directory
body: <p>I am trying to protect some type of files in the /uploads directory from non logged in users in a Wordpress website. The thing is that I am trying to translate the instruction for a Nginx server.</p>
  
  <p>The htaccess syntax would be:</p>
  
  <pre><code>RewriteCond %{REQUEST_FILENAME} ^.*(pdf|doc|docx|ppt|pptx|)$
   RewriteCond %{HTTP_COOKIE} !^.*wordpress_logged_in.*$ [NC]
   RewriteRule . - [R=403,L]
  </code></pre>
  
  <p>I know it is not an "ironclad" solution, but it is enough for my need.
  This is how it should look like:</p>
  
  <pre><code># nginx configuration location ~ ^.*(pdf|doc|docx|ppt|pptx|)$ { }
  </code></pre>
  
  <ol>
  <li>But how should I write the cookie part? </li>
  <li>Moreover how can I add a rule to redirect the user to a specific page?</li>
  </ol>