Page 1 of 1

Preventing Hotlinks

Posted: Sun Jan 05, 2025 6:41 am
by rifathasan
The concept of hotlinking is very simple. You find an image on the internet and use its URL directly on your site. The image will still appear on your site, but it will be served from the original location. This is essentially stealing, as it uses the bandwidth of the site hosting the hotlink. This doesn’t seem like a big deal, but it can add gambling data taiwan up to a lot of extra costs. The Oatmeal is a great example. The Huffington Post hotlinked his multi-image cartoon and it ran up a $1,000+ bill.

hotlinking
Preventing Hotlinks in Apache
To prevent hotlinks in Apache , simply add the following code to the file .htaccess.

RewriteEngine на
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www.)?yourdomain.com [NC]
RewriteRule .(jpg|jpeg|png|gif)$ [NC,R,L]
The second line defines the allowed referrer - the site that is allowed to link to the image directly, this should be your real site. If you want to allow multiple sites, you can duplicate this line and replace the referrer. If you want to create more complex rules, take a look at this hotlink protection htaccess generator.