How to protect against direct access to images? [closed]

http://us3.php.net/image You link the img element to a php file. This file checks if the user has the right permission, if so it can send an img response back. <img src=”https://stackoverflow.com/questions/3990337/url/LoadImg.php?id=1337″ alt=”” /> Still someone with the permission can download the image and provide it to other people somewhere else (webspace/mail/whatever). To make it a … Read more

Allow/deny image hotlinking with .htaccess

RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain\.com [NC] RewriteCond %{HTTP_REFERER} !^http://(www\.)?otherdomain\.com [NC] RewriteRule \.(gif|jpe?g|js|css)$ – [F,NC,L] Will work, as this says. “Refererr is not nothing, and referer is not matching mydomain and referer is not matching otherdomain. If it were the case that you were trying to do the opposite (blacklist a set of domains from … Read more

PHP: How can I block direct URL access to a file, but still allow it to be downloaded by logged in users?

Into folder members create new folder files, move here all your songs, create new .htaccess file and add the following lines: Order Deny,Allow Deny from all Into folder members create file get_song.php and add the following code: if( !empty( $_GET[‘name’] ) ) { // check if user is logged if( is_logged() ) { $song_name = … Read more

How to prevent a file from direct URL Access?

Try the following: RewriteEngine on RewriteCond %{HTTP_REFERER} !^http://(www\.)?localhost [NC] RewriteCond %{HTTP_REFERER} !^http://(www\.)?localhost.*$ [NC] RewriteRule \.(gif|jpg)$ – [F] Returns 403, if you access images directly, but allows them to be displayed on site. Note: It is possible that when you open some page with image and then copy that image’s path into the address bar you … Read more