HOW DO I STOP HOTLINKING AND BANDWIDTH THEFT?
You can stop servers from hotlinking your site's files by editing the
.htaccess file in your site's root directory. (Consult your webhost on accessing your
.htaccess file.)
Example: Your site url is
www.example.com. To stop hotlinking images from an outside domain and display an image called
nohotlink.jpg instead, use this code in your
.htaccess file:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^
http://(www\.)?example\.com/ [NC
RewriteCond %{HTTP_REFERER} !^$
RewriteRule \.(jpe?g|gif|bmp|png)$ images/nohotlink.jpg [L]
To allow hotlinking images only if the REFERER (sic) is from a specific directory from your domain:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^
http://(www\.)?example\.com/dir/ [NC
RewriteCond %{HTTP_REFERER} !^$
RewriteRule \.(jpe?g|gif|bmp|png)$ images/nohotlink.jpg [L]
To stop hotlinking images from specific outside domains only, named
badsite.net and
badsite.com:
RewriteEngine On
RewriteCond %{HTTP_REFERER} ^
http://(www\.)?badsite\.net/ [NC,OR
RewriteCond %{HTTP_REFERER} ^
http://(www\.)?badsite\.com/ [NC
RewriteRule \.(jpe?g|gif|bmp|png)$ images/nohotlink.jpg [L]
Limit bandwidth usage by returning a 403 forbidden code. Replace the last line of the previous examples with this line:
RewriteRule \.(jpe?g|gif|bmp|png)$ - [F]
<img height="1" width="1" border="0" src="http://pagead2.googlesyndication.com/pagead/imp.gif?event=noiframe&client=ca-pub-3963608149933108&dt=1129671446109&lmt=1108 428680&alternate_ad_url=http%3A%2F%2Faltlab.co m%2***ar.cgi%3Finput_mode%3Dsoftware%26input_id%3D 229637&format=120x600_as&output=html&c hannel=7284726313&url=http%3A%2F%2Faltlab.com% 2Fhtaccess_tutorial.html&color_bg=F8F8F8&c olor_text=666666&color_link=CC0000&color_u rl=999999&color_border=F8F8F8&ref=http%3A% 2F%2Fwww.google.com%2Fsearch%3Fhs%3DLVy%26hl%3Den% 26lr%3D%26client%3Dfirefox-a%26rls%3Dorg.mozilla%253Aen-US%253Aofficial_s%26q%3Dhotlink%2Bhtaccess%26btnG% 3DSearch&cc=92&u_h=864&u_w=1152&u_ ah=830&u_aw=1152&u_cd=32&u_tz=-240&u_his=6&u_java=true&u_nplug=24& ;u_nmime=96" />
Warning: Do not use .htaccess to redirect image hotlinks to another HTML page or server that isn't your own (such as this web page). Hotlinked images can only be redirected to other images, not to HTML pages.
As with any
.htaccess rewrites, you
may block some legitimate traffic (such as users behind proxies or privacy firewalls) using these techniques.