-1

I want to restrict the file access via url and also I need to allow from html view page. My code is like this means

<img src="../webroot/images/logo.png" alt="logo">

The attacker simply go to inspect element and copy paste the url and get the original file from my server. Some images are user privacy so how can I prevent it. I just also tried this htaccess method but it restrict on both from url and also in html view page.

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://localhost$ [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ http://localhost/skypeclass [R,NC]
Sankar Smith
  • 338
  • 1
  • 5
  • 14

1 Answers1

0

Try below in your .htaccess

<Files ~\.(jpg|jpeg|gif|png|bmp)$>
   Order Deny,allow
   Deny from all
   allow from 127.0.0.1
</Files>
Abhishek Gurjar
  • 7,426
  • 10
  • 37
  • 45