Restrict Access to a sub driectory
-
I am trying to restrict access to a a sub directory and its files I made in my uploads folder. URL /wordpress/wp-content/uploads/protected/
I want to stop people from putting in a direct URL and getting specific files.
IE:URL /wordpress/wp-content/uploads/protected/file-nane.pdfNot all files will be PDFs.
I tried adding a .htaccess file to the directory with this in it:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(www\.)?URL\.com/ [NC]
RewriteCond %{REQUEST_URI} !hotlink\.(gif|png|jpg|doc|xls|pdf|html|htm|xlsx|docx|mp4|mov) [NC]
RewriteCond %{HTTP_COOKIE} !^.*wordpress_logged_in.*$ [NC]
RewriteRule .*\.(gif|png|jpg|doc|xls|pdf|html|htm|xlsx|docx|mp4|mov)$ http://URL/ [NC]You can’t get to the main directory, but you can still link directly to the files. I only want logged in users to be able to access the files.
Thoughts?
The topic ‘Restrict Access to a sub driectory’ is closed to new replies.