How Do I Stop Hotlinking and Bandwidth Theft?
You can stop people from hotlinking your files (and leeching your bandwidth) by creating an .htaccess file and adding the following lines to it:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://([-a-z0-9]+\.)?yourdomain\.com [NC]
RewriteRule \.(gif|jpe?g|png)$ - [F,NC,L]
There are many variations of this scheme out there however I found many of them DID NOT WORK! For example the NC switch does not work with my host (I don't know why) I have filenames in upercase and I had to add JPE?G to the RewriteRule line:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://([-a-z0-9]+\.)?dorkytutorial\.com [NC]
RewriteRule \.(gif|jpe?g|JPE?G|png)$ - [F,NC,L]
I also tried other varitions of the above script where the user would be redirected to another file of some sort: (this came from http://underscorebleach.net/jotsheet/2004/11/stop-image-hotlinking-tutorial-htaccess-apache )
RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g|png)$ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !underscorebleach\.net [NC]
RewriteCond %{HTTP_REFERER} !bloglines\.com [NC]
RewriteCond %{HTTP_REFERER} !google\. [NC]
RewriteCond %{HTTP_REFERER} !search\?q=cache [NC]
RewriteRule (.*) /view_image.shtml?/$1 [R,NC,L]
It worked fine except the redirecting to the view_image.shtml didn't work. Source for view_image.shtml can be found here. There is also PHP scripts that will do the job as well, but I didn't get into those.

0 Comments:
Post a Comment
<< Home