block image link to other sites

0

I have the following folder in the root of my site:

Arquivos/Fotos/goto1.jpg

If I type in the browser the link with my site (www.mysite.com/Arquivos/Photos/goto1.jpg) the photo opens, and is it possible to block it? I mean let the photo only appear within the pages of my site?

    
asked by anonymous 26.07.2016 / 14:18

1 answer

1

Yes, it is possible!

You can try the following in .htaccess (Apache):

RewriteEngine on 
RewriteCond %{HTTP_REFERER} !^http://(www\.)?localhost [NC] 
RewriteCond %{HTTP_REFERER} !^http://(www\.)?localhost.*$ [NC] 
RewriteRule \.(gif|jpg)$ - [F]

You can do the same in IIS using Web.config, but I do not know how.

The example above, using Apache, has localhost as a domain, make sure you use the correct domain instead of " localhost ".

    
26.07.2016 / 14:27