Is it possible to distinguish between hotlinking and regular linking of images using .htaccess?

I think there is no answer to this question, but ideally I would like to be able to allow hotlinking of images, but redirect regular links. For example, if someone uses this, it should work as expected:

<img src='http://mysite.com/image.jpg'/> 

But if they use this, it will be redirected to another page when visiting:

 <a href='http://mysite.com/image.jpg'>Click Here</a> 

I believe $HTTP_REFERER is the same, regardless of two methods. Is there any other smart way to distinguish these two?

+4
source share
1 answer

Many browsers send different Accpet: headers Accpet: in these two situations.

When requesting a resource from <img src="xxx"> :

 Accept: */* 

When requesting a URL in the address bar:

 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 
+1
source

Source: https://habr.com/ru/post/1411392/


All Articles