Skip to content


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:

RewriteEngine On
# 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: 9% [?]

Posted in Snippets, SysAdmin.


2 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

Continuing the Discussion

  1. damonparker.org » Logging and Monitoring Apache linked to this post on 8/4/2005

    [...] An introduction to Service Data Objects for PHP | Home | Stop Bandwidth Thieves 8/4/2005 Logging and Monitoring Apache [...]

  2. damonparker.org - Stop Bandwidth Theives - Lighttpd Style linked to this post on 10/10/2005

    [...] Previous hotlinking post provided a solution for Apache servers only. Here is one for Lighttpd. [...]



Some HTML is OK

or, reply to this post via trackback.