8/4/2005
Stop Bandwidth Thieves
Hotlinking can be a major pain on highly loaded servers. Hotlinking is where another site links directly to your images/movies/downloads on their site effectively making you pay (in bandwidth and server usage) for people to view your content on their site.
One client, I saw a 40G pipe that always became saturated in the middle of the day drop to below ~32G at peak after hotlink protection was enabled.
To stop hotlinking add a .htaccess file in your root directory with something like the following:
# replace domain.com with your domain name
# also allows for http://domain.com and http://www.domain.com
RewriteCond %{HTTP_REFERER} !^http://(www\.)?domain\.com/ [NC]
# skips if http_referer is not passed by client
RewriteCond %{HTTP_REFERER} !^$
# send a nasty image instead (make it a small one)
RewriteRule \.(jpe?g|gif|png)$ /images/goaway.jpg [L]
# or save bandwidth all together by just sending an error back
#RewriteRule \.(jpe?g|gif|png)$ - [F]
Popularity: 14%



August 4th, 2005 at 11:18 am
[…] An introduction to Service Data Objects for PHP | Home | Stop Bandwidth Thieves 8/4/2005 Logging and Monitoring Apache […]
October 10th, 2005 at 11:00 am
[…] Previous hotlinking post provided a solution for Apache servers only. Here is one for Lighttpd. […]