This tutorial provides 2 solutions which enable you to prevent other websites from directly linking to image files on your website.
This stops websites from using your server resources to host your images on their website. Hotlinking can result in a increase in bandwidth forcing you to upgrade your hosting plan.
To prevent hotlinking, you can:
- Enable Hotlink Protection in cPanel if your host includes this feature. Both Bluehost and Hostgator include Hotlink Protection in cPanel.
- Create Apache server mod_rewrite directives for your .htaccess file which do the same thing as hotlink protection however enable more flexibility with customization of the rules.
1. Turn On Hotlink Protection in cPanel
If you’re using a host like Hostgator or BlueHost, simply login to cPanel and scroll down to the security section where you’ll find Hotlink Protection:
You can then enter the allowed URL’s like your own and image file extensions you want to block other sites from hotlinking to.
2. Create .htaccess rewrite directives
The 2nd method involves using rewrite conditions in your .htaccess file.
You can edit an existing example or generate new rules using an online .htaccess tool.
Here’s 1 example you can test first before using on a live production site.
Simply replace example.dev with your domain in the code.
Video Demonstration 1 min 26 seconds
The video shows you where to paste the code in your .htaccess file.
It also shows you how the code doesn’t disable images on your own domain but does when you change the domain in the code to something other than your domain.Subscribe to Free Tutorials