Image hot-linking is (simply put): other site is showing your image that still on your server. This can cause problem for bandwidth limited website, they steal your bandwidth! Also, this doesn’t make visitor from that notorious site to come to your site. More visitor for them, more bandwidth lost for you. We will handle this issue using htaccess.
Remember that to use .htaccess fully (including this tips), you have to activate Apache mod_rewrite.
In our case, we will allow only few sites that directly show/link our image. Other sites that have no permission will show an error/no leech image. This is the full .htaccess code:
1 2 3 4 5 6 7 8 9 10 11 12 | <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{HTTP_USER_AGENT} ^facebookexternalhit.*$ [OR] RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?ahowto.net [NC] RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?mp32u.net [NC] RewriteCond %{HTTP_REFERER} !^.*google.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^.*bing.com/.*$ [NC] RewriteCond %{REQUEST_URI} !^/images/no_leech.jpg RewriteRule \.(jpe?g|png|gif)$ http://www.ahowto.net/images/no_leech.jpg [L] </IfModule> |
Yes, I know that there are few “anti-leech/anti-hot-link” plugins out there, but make sure they have the correct htaccess code placement. Make sure the placement is before main wordpress htaccess default code. So, your wordpress blog htaccess code would be like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | # BEGIN Hotlink Protection <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{HTTP_USER_AGENT} ^facebookexternalhit.*$ [OR] RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?ahowto.net [NC] RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?mp32u.net [NC] RewriteCond %{HTTP_REFERER} !^.*google.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^.*bing.com/.*$ [NC] RewriteCond %{REQUEST_URI} !^/images/no_leech.jpg RewriteRule \.(jpe?g|png|gif)$ http://www.ahowto.net/images/no_leech.jpg [L] </IfModule> # END Hotlink Protection # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress |