Friday, March 25, 2011

Hotlinking

Hotlinking:
Let's say i own example.com and i have webpage test.html accessible through www.example.com/test.html and test.html is codes as

<body>
          <img src="rizwan.com/image1.jpg"/>
</body>

Now when you load example.com/test.html , image1 will be loaded from rizwan.com and not from example.com. So i have hotlinked image1 from my webpage to rizwan.com

Problem:
             Since bandwidth is charged, and i have asked your browser to show that 500KB (lets assume) image1 from answer.com , answer.com is going to pay for that bandwidth , not example.com. Hence bandwidth theft.

Solution:
            Http Referrer can be used to identify if image1 is being linked from any other site except answer.com. If yes , then we can simply reject the request or do whatever you like.
How can we check the referrer? Well Conditional Rewrite rules can help.

RewriteCond %{HTTP_REFERRE] !^http://(www\.)?answer.com/.*$
RewriteRule \.*/image1.jpg$ /image/sucker.jpg [L]


Well , first condition checks if referrer is anything except our website, if yes then next rewrite rule is excuted and alternate image is sent instead of image1.jpg, You can as well return 404 , a low bandwidth image etc

No comments:

Post a Comment