Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR HTML

disable pdf download to not logged in users wordpress

<IfModule mod_rewrite.c>
  RewriteEngine On
  # If a not logged in user tries to download a file it will redirect to home:
  ErrorDocument 403 https://www.yoursite.com/
  RewriteCond %{REQUEST_FILENAME} (.*)
  # requires a cookie (wordpress login) for downloading media files
  RewriteCond %{HTTP_COOKIE} !wordpress_logged_in_([a-zA-Z0-9_]*) [NC]
  # Add more document extensions here. 
  # If you add image types (jpg,gif...) they woun't be shown to not logged users!
  RewriteRule .(zip|doc|docx|pdf)$ – [NC,F,L]
</IfModule>
 
PREVIOUS NEXT
Tagged: #disable #pdf #download #logged #users #wordpress
ADD COMMENT
Topic
Name
4+3 =