A
A
Albert Ushakov2021-02-24 18:36:45
PHP
Albert Ushakov, 2021-02-24 18:36:45

How to protect the site from direct links to images with image inserts on other sites?

The question is simple in principle, but I did not find the answer for myself on the net.
That is, it is proposed to prohibit through htaccess, for example, like this,

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?sitename.ru [NC]

RewriteRule \.(jpg|jpeg|png|gif)$ http://dropbox.com/hotlink-placeholder.jpg [NC,R,L]

But this code does not solve the problem of inserting images on other resources. Pictures continue to be displayed and send requests to the server.
In general, how to properly implement this protection through htaccess or through PHP? Can you share your thoughts on this.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Druzhaev, 2021-02-25
@OtshelnikFm

Close the site for the Internet.
Because what happened to the Internet is no longer protected. Pictures print on the printer and put in a safe. Then they won't steal.
And so - the fight against windmills.

B
bkosun, 2021-02-25
@bkosun

It makes no sense to block on HTTP_REFERER, since such protection is easily bypassed. Use dynamic links.
https://serverfault.com/questions/966563/how-to-pr...
https://stackoverflow.com/questions/3990337/how-to...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question