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