I just used this .htaccess
code from this post How to prevent a file from direct URL Access?
that they say it working.
But for me it doesn’t work. Any suggest?
My goal is to block direct access to a file (example http://localhost/webapp/files/test.jpg
) if a user write the url in the browser. But i’d like to view the image if it is embedded in a page (inside my localhost/webapp/ of course) like this: <img src="https://localhost/webapp/files/test.jpg">
With the code above, also img src is blocked…
I’m trying the code using WAMP SERVER to test it
.htaccess (inside folder localhost/webapp/files/)
# Disable directory browsing
Options All -Indexes
# Restrict access to this directory
Order deny,allow
Deny from all
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(www.)?localhost [NC]
RewriteCond %{HTTP_REFERER} !^http://(www.)?localhost.*$ [NC]
RewriteRule .(gif|png|jpg)$ - [F]