« Firefox Friends Wall in Firefox 2 | Main | the answer to life, the universe and everything »

Avoiding Hot Linking to Images

Home » Programming » Mod_rewrite

Bandwidth is precious, and seeing a bandwidth limit exceeded on your website is just so frustrating. Blocking unwanted referrers from your site may be your best option. If you are using apache as your webserver then you can take advantage of its mod_rewrite module to block unwanted referrers.

You need to modify your .htaccess file to block access to large files such as, images, mpeg, avi, etc. :

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://([-a-z0-9]+\.)?domain\.com [NC]
RewriteRule .*\.(jpg|gif|avi|wmv|mpg|mpeg)$ http://www.domain.com/nohotlink.jpg [R,NC,L]
</ifModule>

TrackBack

TrackBack URL for this entry:
http://www.tildemark.com/cgi-bin/mt/mt-tb.cgi/24

Listed below are links to weblogs that reference Avoiding Hot Linking to Images :

» Blocking unwanted referrers from Tildemark blogs
Looks like my post to avoid linking to hot images is not working, now i'm getting 85% bandwidth usage on my website. When i try to view the logs got numerous referrers from profiles.myspace.com. Alright, i have decided to block... [Read More]

About

This page contains a single entry from the blog posted on September 7, 2006 1:01 PM .

The previous post in this blog was Firefox Friends Wall in Firefox 2 .

The next post in this blog is the answer to life, the universe and everything .

Many more can be found on the main index page or by looking through the archives .

Creative Commons License
This weblog is licensed under a Creative Commons License .
Powered by
Movable Type 3.33