You may see htaccess code such as this claiming to provide anti-leech control for, in this case, gif jpg and png files. What this code does is stop any request that was not referred from the yoursite.com domain name.
Code: Select all
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !error.gif$
RewriteCond %{HTTP_REFERER} !yourdomain.com
RewriteRule \.(gif|jpg|png)$ /error.gif [L]
You can kid yourself into thinking it works, and run a test that shows it does. But it only blocks people who are sending you an invalid referrer code. Maybe better than nothing, but not much better. All those people who get blockled will just go somewhere else assuming your website has too many errors since your images will not show.
To solve this problem, you see many examples like this:
Code: Select all
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !error.gif$
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !yourdomain.com
RewriteRule \.(gif|jpg|png)$ /error.gif [L]
Then, to make matters worse, the referrer code can be easily faked anyway.
If you want to protect your images, consider using a watermark and denying access to the original unwatermarked copy. You can find a watermark script and associated access control instructions this Tips & Scripts page.
If you are having trouble with a site leeching taking too much bandwidth, block that site. You can find instructions for blocking traffic to your website on this Tips & Scripts page.