How to Enable Hotlink Protection in cPanel

Hotlinking is the practice used by webmasters to directly link a media file (e.g. a photo or a video) from your website and display it on their web without saving a local copy on their server.

Without hotlink protection, other websites could be consuming your hosting bandwidth and this can lead to slow loading websites or higher costs of your hosting plans.

In this guide, we are going to take you through the steps of enabling hotlink protection and disabling other sites from loading media files directly from your website. We can enable this feature right from your cPanel account.

Prerequisites

  • A domain name e.g. www.example.com
  • Web hosting account that supports Cpanel
  • Cpanel username and password.

Step 1: Login to your cPanel account

The first step is to log in to your cPanel account. Just enter your domain name followed by ‘/cpanel’ on a web browser, enter your username and password and hit ‘Log In’ to proceed.

Step 2: Locate hotlink protection from the dashboard

On the search box, type ‘hotlink protection’ and click the icon that appears below as shown:

Step 3: Use the hotlink manager to customize the settings

At the top of the screen, you will see the text, ‘Hotlink protection is currently “disabled”Just click the ‘Enable’ button under the text to activate the feature.

From this point forward, other websites will not be able to directly to your site files. However, to avoid completely locking your other websites from linking to the files, you should enter all your domains including their ‘www’ aliases under the ‘URLs to allow access:’ textbox.

For instance, if your website is www.example.com, make sure you have entered the below entries.

At the bottom of the screen, you will see an option of specifying the file extensions that you want to protect.

The file extensions that you want to block should be separated with commas. Then, check the option ‘Allow direct requests (for example, when you enter the URL of an image in a browser)

This option is useful if you want to directly download or access files from your website without visiting a complete web page directly.

You may enter a value on the field labelled, ‘Redirect the request to the following URL:’ if you specify a value here, users trying to access your hotlink protected files will be directed to the URL. You may leave this text box intact

Then click on submit button as shown:

 

If everything is setup correctly, you should see a success message:

Step 4: Test the setup

Once you make any change on your cPanel account, it is advisable to test the settings in the production environment. To see whether hotlinking protection was enabled, create a sample HTML file and save it on your computer with ‘.html’ extension (e.g. hotlink.html), then reference any image from your hotlink protected website on that file.

<html>
  <head>
    <title>
    A Simple HTML Document
    </title>
  </head>
  <body>
    <img src='http://www.example.com/test.gif'>
  </body>
</html>

Then upload your file on a different website using an FTP client or cPanel File Manager and open your file on a browser (e.g. Internet Explorer or Chrome). If hotlinking protection is working as expected, you should see a broken link image instead of the hotlinked image as shown:

Conclusion

In this article, we have talked about hotlinking and how it can negatively affect your websites in terms of bandwidth. We have also taken you through the steps of enabling the feature in cPanel to protect other websites from ‘stealing’ your bandwidth. With the feature enabled, you will have a better experience of your website.

Check out the top 3 cPanel hosting services:

Was this article helpful?