title: Prevent direct access to uploads folder for non-loggedin user (WordPress)
body: <p>I want to prevent non-logged in user to direct access from uploads folder inside wp-content. I have tried by putting the following rules in htaccess.conf in the AWS Lightsail server. After that, it's working fine but the site is broken now. Can anyone help me to figure out why it's broken? When I remove the rules from htaccess.conf the site loads fine. </p>
  
  <pre><code>&lt;Directory "/opt/bitnami/apps/wordpress/htdocs/"&gt;
  # Protect all files within the uploads folder
  &lt;IfModule mod_rewrite.c&gt;
      RewriteEngine On
      RewriteCond %{HTTP_COOKIE} !.*wordpress_logged_in.*$ [NC]
      RewriteCond %{REQUEST_URI} ^(.*?/?)wp-content/uploads/.* [NC]
      RewriteRule . https://%{HTTP_HOST}%1/wp-login.php?redirect_to=%{REQUEST_URI} [L,QSA]
  &lt;/IfModule&gt;
  &lt;/Directory&gt;
  </code></pre>