How to protect images / files and other resources for logged in users only in wordpress?

1080 views December 6, 2021 0

Add the following line in the .htaccess file of your WordPress to prevent the access of downloadable resources without authentication.

 Add this lines below the “RewriteBase  /”

RewriteCond %{REQUEST_FILENAME} ^.*(png|pdf|jpeg|gif|bmp|pdf|doc)$
RewriteCond %{HTTP_COOKIE} !^.*wordpress_logged_in.*$ [NC]
RewriteRule . – [R=403,L]

You can prevent the access of any downloadable resources by adding its file type in line 1 above. eg. mp3, jpeg etc.

Was this helpful?

Hello there!

Need Help? We are right here!

Contact miniOrange Support

Thanks for your inquiry.

If you dont hear from us within 24 hours, please feel free to send a follow up email to