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

  1. Login to your cPanel account.
  2. Under the Security section, select the HotLink Protection option.
    cpanel hotlink protection
  3. On the new page, click the Enable button, under the section Hotlink Protection.
    cpanel hotlink protection enable
  4. You will receive a Hotlink Protection Enabled success message on the new screen.
    cpanel hotlink enable success
  5. Click on the Go Back button at the bottom of the screen.
    cpanel hotlink goback
  6. 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.
    cpanel configure hotlink
  7. Click on Submit at the bottom of the page. You will receive a success message with the URLs and extensions.
    cpanel hotlink submit

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!

Add a Comment

Your email address will not be published. Required fields are marked *