Do you have an image or images that people are using on their site, Not giving you the credit for your artwork and using your bandwidth?
With a simple .htaccess on your Apache server you can prevent Image HotLinking.
In your Images Directory, or in your mail web root if you have multiple image areas create a .htaccess file. If you already have one, we can just append the following code in to that.
Insert this in to your file.
RewriteEngine On # REPLACE lendrum\.co.nz WITH YOUR DOMAIN NAME RewriteCond %{HTTP_REFERER} !^http://(.+\.)?lendrum\.co\.nz/ [NC] RewriteCond %{HTTP_REFERER} !^$ RewriteRule .*\.(jpe?g|gif|bmp|png)$ - [F]
This will send a 403- Forbidden message to all external sites calling your images.
You can allow multiple domains to access the images if you have more pointing to your site, or want certain sites to use your images.
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?lendrum\.co\.nz/ [NC] RewriteCond %{HTTP_REFERER} !^http://(.+\.)?inboxdesign\.co\.nz/ [NC] RewriteCond %{HTTP_REFERER} !^http://(.+\.)?apple\.co\.nz/ [NC] RewriteCond %{HTTP_REFERER} !^http://(.+\.)?apple\.com/ [NC]
If you want to send a different image, rather than a 403 error you can change the last line to this: But this is almost defeating the purpose, but it will let the visitors on the other sites know that the webmaster is an image thief
RewriteRule .*\.(jpe?g|gif|bmp|png)$ /images/DoNotSteelMyImages.jpg [L]
Simple
Note: This will only work on Apache Servers.
Related posts:

One Response to “Preventing Image theft with Apache's .htaccess”
Cenk 12/08/2008 04:26pm
Thanks Sheldon.