Fun with mod_rewrite.  

Let's say you have a site with nice graphics on it.. Beautifull pictures.. nice art.. or smileys..
Some people, especialy n00bs with 'profile sites' have a tendency to deeplink to those images..
That is nice for them.. Content on their site for free..
But who pays for the bandwidth ?? you !!

So what to do..
Thanks to the wonderfull apache mod_rewrite it is not that hard to do something about it..
In your main webfolder place a .htaccess file containing something like this:
RewriteEngine On
RewriteBase /

#allow users coming from friendly sites
RewriteCond %{HTTP_REFERER} !^http://(www.|)yoursite.tld/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www.|)afriend.tld/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www.|)lame.tld/~friend.*$ [NC]

#otherwise, send warning
RewriteRule .*\.(jpg|gif|png|bmp)$ http://etv.cx/yousuckandthatssad.gif

But that's too friendly in some cases..

» Read More