block image link to other websites

Asked

Viewed 91 times

0

Guys I have the following folder at the root of my site:

Arquivos/Fotos/goto1.jpg

If I type in the browser the link co my site (www.meusite.com.br/Files/Photos/goto1.jpg) the photo opens, and possible block this? That is to allow the photo to only be displayed within the pages of my website?

1 answer

1


Yes, it is possible!

You can try the following on .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 on IIS using Web.config, but I don’t know how to do it.

The above example, using Apache, has localhost as its domain, make sure to use the correct domain in place of "localhost".

  • Hi, I tried to use this in my htacess, but even my site is not opening the photos. What can be?

  • See the list of extensions, please. I listed only two: . gif and . jpg Hug

  • well as I understand it was for gif and jpg to be read only by the html of my site, right? this does not occur, when I use the code you gave me it blocks the image to my site tbm, as if the image did not exist.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.