Protect Hotlink the Right Way Using htaccess

by Hiroshi on December 31, 2009

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} !^https://(.+.)?yoursitename.com/ [NC]
RewriteCond %{HTTP_REFERER} !^https://(www.)?google.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^https://(www.)?feedburner.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^https://(www.)?feeds2.feedburner.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*.(jpe?g|gif|bmp|png|zip|rar)$ https://yoursitename.com/someimage.jpg [L]

Related Posts

Previous post:

Next post: