PlanetMike.com

Blog

Michael Clark's journal of important and not-so-important thoughts.

You are currently browsing the PlanetMike’s Technology Journal weblog archives for May, 2007.



Support Me

Please support Michael Clark

Last 10 Articles


Categories


Archives


MonthChunks


Archive for May, 2007

Using Apache to Block Image Leeches

Tuesday, May 15th, 2007 7:46 am

Pronet Advertising advises you to “Protect Your Site’s Content” and they give a plug to a $200 tool that helps those poor souls using IIS as their web server. If you’re running the open source apache web server, here’s a free solution I worked out after many MySpace users starting embedding funny photos from PlanetMike.com into their web pages:

  1. Create an image to send to people that attempt to leech your images. you could be rude or mean, but I simply put up an ad for my own web site. Keep it as small as you can, since it may be used a lot. My photo is at http://www.planetmike.com/images/no-hot/linking.jpg.
  2. Ideally, put this into a directory block in your httpd settings file. Or you can put it into your .htaccess file.
    RewriteEngine onRewriteCond %{REQUEST_FILENAME} !^/images/no-hot/linking\.jpg$RewriteCond %{HTTP_REFERER} !^$ [NC]RewriteCond %{HTTP_REFERER} !^http://(www\.)?planetmike.com/ [NC]RewriteRule \.(jpe?g)$ /images/no-hot/linking.jpg [L]RewriteEngine off

    Line 2 is the image you want people to see (your ad or nasty note).

    Line 3 allows normal images to be sent to people who don’t send a referrer.

    Change line 4 to be your domain name. This domain will be allowed.

    Line 5 changes what image is sent on image requests. If a jpg is requested send the replacement image.

  3. Restart your web server and test.

That’s all there is to it. Definitely let me know if you have problem with this.

If you're new here, you may want to subscribe to my RSS feed. This allows you to read my newer articles without having to visit the site again. Thanks for visiting! Mike

Subscribe by RSS

Use my RSS feed to stay up to date


WordPress Plugins


Most Popular Posts


Stuff


Copyright © 1997-2008 Michael Boyd Clark
PlanetMike’s Technology Journal is proudly powered by WordPress
Entries (RSS) and Comments (RSS).