Home Portfolio Trips Extras About Us Site Map |
Recently we had a problem with someone 'hotlinking'¹ to a single 66kb image from the site, as he was using the image for his 'logo' on a forum every post he added caused more hits. Then we had an adult site link to an image of a house and cause a HUGE bandwidth hit.
Paste the below code into your .htaccess file in either your root directory or the directory with the hotlinking problem:
RewriteEngine on RewriteCond %{HTTP_REFERER} ^http://www.evil-hotlinking-domain.com/ [NC] RewriteRule .*\.jpg$ - [F]and then change www.evil-hotlinking-domain.com to whatever the problem referrer is.
Brief explanation - The second line checks if the referrer contains the string 'http://www.evil-hotlinking-domain.com/' (the [NC] makes the comparison case insensitive). The final line points any jpg request from the above referrer to 403 Forbidden.
This code will send a '403 Forbidden' code back to the requesting client, it is possible to redirect the request to a different image instead but is not something we have done yet. However, 3 weeks after putting the block in place the requests from the forum are still coming in and being sent away with a 403. It's a pain to see them all in the log files and sending the 403 still uses bandwidth - though not nearly so much. I just hope that some day soon the offender clears his cache and notices the black square with the red cross in it on all of his posts... Here is the redirecting code:
RewriteEngine on RewriteCond %{HTTP_REFERER} ^http://www.evil-hotlinking-domain.com/ [NC] RewriteRule \.jpg$ http://www.your-domain-name.com/goaway.jpg [R,L]In this case you need to substitute www.evil-hotlinking-domain.com for the offending referrer and www.your-domain-name.com/goaway.jpg for your website address and the path to the replacement image. This solution will use bandwidth at a higher rate than returning the 403, no matter how small you make the image you redirect to ( unless you have a huge custom 403 ). Could be a lot more fun though }-)
NOTE: you need to check with your own hosting provider to see what level of .htaccess support they provide - sometimes it is limited to only ErrorDocuments or is disallowed entirely.
Useful external links:
© 2004 Dana & Andy Dopleach info@bylandwaterandair.com Site Map