How to block Image Hotlinks with warning?

Asked

Viewed 462 times

5

A little while ago I saw a site that was displaying an image hosted on another site, at least trying.. What happens is that on the site that was linking the image of others started to appear a new image instead of the desired image.

The new image consisted of a simple rectangle with the phrase indicating that the image was being "copied", observing the sources of the site clearly noted the Hotlink:


inserir a descrição da imagem aqui


My site already has on .htaccess the blockade for the Hotlinks:

RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?nome_do_meu_site.com.br [NC]

But how to add this mentioned functionality?

1 answer

4


Put this in your htaccess:

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?meusite\.com\.br/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ /imagem/anticopia.jpg [L]

After that, create an image with the desired text or whatever, and change that part of the code with the directory and image name

/image/anticopy.jpg

Also change, of course, the "meusite.com.br"

I use this tool on my site and find it very useful.

Browser other questions tagged

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