Protect Hotlink the Right Way Using htaccess
December 31st, 2009 | by King | Posted in » htaccess
Protect hotlinking the right way. There are content stealers out there who will copy your links and images and display them at their websites in result of which you pay more for bandwidth. If you do not do it the right way, you can block google and feedburner also. Here is a code to do it the right way. Any incoming direct request for your image file, zip file or rar will will display your specified image instead of that.
Add this code into your .htaccess file and make sure you change ‘yoursitename’ there.
Options +FollowSymlinks
# Protect Hotlinking
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+.)?yoursitename.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www.)?google.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www.)?feedburner.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www.)?feeds2.feedburner.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*.(jpe?g|gif|bmp|png|zip|rar)$ http://yoursitename.com/someimage.jpg [L]
iphone konig Says:
thanks for this – happy holidays :D
iphonekönig Says:
happy new year – love your blog
Nick Matyas Says:
this is an outstanding blog
the way u write is fabolous.
Thanks a lot