What Is Hotlink Protection And How To Prevent Hotlink?
In this article, we will discuss Hotlink Protection and how to prevent Hotlink.
What Is HotLink?
Hotlinking is the act of linking a file that is hosted on another site, instead of downloading the file and re-uploading it on your server. Most commonly images, audio files, and flash animations are hotlinked, but sometimes other digital assets like movies, are hotlinked.
Since hotlinking requires the website hosting the file to use its bandwidth to load it on your site, it is considered unethical, and some even call it stealing. That’s because it swallows up the bandwidth of the site you took it from without giving them the benefit of increased traffic. In other words, you are virtually making that website pay for part of your hosting bill.
What is Hotlink Protection?
Hotlink protection prevents other websites from directly linking to files and pictures on your website. There are a few ways to enable hotlink protection for your website.
Enable Hotlink Protection from cPanel
- Login to your cPanel account.
- Under the Security section, select the HotLink Protection option.
- On the new page, click the Enable button, under the section Hotlink Protection.
- You will receive a Hotlink Protection Enabled success message on the new screen.
- Click on the Go Back button at the bottom of the screen.
- Now, let us configure hotlink protection. Add all the URLs under the section ‘URLs to allow access’. Add the extensions you want to block direct access in the tab. Separate each extension using a comma.
- Click on Submit at the bottom of the page. You will receive a success message with the URLs and extensions.
Enable Hotlink protection via .htaccess
Enable Hotlink protection via the .htaccess file is pretty straightforward. You just need to add the below code in your .htaccess file.
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^https://(www.)?my-website.com/.*$ [NC]
RewriteRule .(jpg|jpeg|gif|png|bmp)$ – [F]
This above code will redirect any requests for images from other websites to a blank page. You can also change the last line to redirect to a specific page by using the code below.
RewriteRule .(jpg|jpeg|gif|png|bmp)$ https://www.yourwebsite.com/restricted.png [R,L]
Thats it! Your images are safe and Hotlink Protection And How To Prevent hotlink is done.
If you enjoyed this tutorial, then you would love our support! All Kemuhost hosting plans include 24/7 support from our amazing support team. Check out our web hosting plans and have your website migrated for free today!