2006 02 14: Remember kids, deeplinking is dangerous..
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
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..
If it's your own server, you can in the VirtualHost in the httpd.conf place something like:
RewriteMap images rnd:/home/you/images
In that file you place the following (warning explicit images):
img femse.com/images/Miss-goatse.jpg|http://www.zippercow.com/ashton/tubgirl.jpg|goatse.ragingfist.net/hello.jpg
And in the .htaccess file replace the RewriteRule with:
RewriteRule .*\.(jpg|gif|png|bmp)$ http://${images:img}
That should warn even the worst kind of bandwidth thieves..
So how does that make a bandwidth thief look: NSFW !!

Total Votes: 5 - Rating: 4.40
jan wrote: