PHPMatters Help You Better Hosting Your PHP-based Sites
How to Enable HotLink Protection via cPanel, .htaccess and Plugin

How to Enable HotLink Protection via cPanel, .htaccess and Plugin

HotLink Protection is a common hosting feature offered by the majority of quality and reliable web hosting providers. It is used to prevent your site from suffering the issue of hotlinking, and in the meanwhile, help you avoid the outbound traffic and over-consumption of bandwidth caused by some outside websites.

In the following, we’d like to showcase a detailed introduction about this hosting feature, along with how to enable it to better protect your website via cPanel, plugins and .htaccess.

Enable HotLink Protection using cPanel

This is a default feature of cPanel control panel. Therefore, if your web host provides you with cPanel for website management, you can take advantages of this hosting feature easily.

After logging into your control panel, you need to navigate to the Security area and click the HotLink Protection icon.

HotLink Protection Icon

By default, HotLink Protection is currently enabled. What you should do is to determine the following aspects.

  • You need to enter the URLs that are allowed to use your images, including your own domain and the domains of your other websites hosted within the same web server.
  • You also need to enter the file types you want to protect with their exclusive extensions. The common extensions include jpg, gif, png, bmp and jpeg.
  • If you want your images to be showed in a browser by entering the image link, you should check the box of allowing direct requests.

HotLink Protection Settings

After entering these blank spaces and clicking the submit button, you can have your images protected from being hotlinked.

Enable HotLink Protection using .htaccess

If your control panel is not the cPanel one, you can also enable the HotLink Protection using the .htaccess code. The following image showcases the standard coding stuff for the prevention of hotlinking in terms of the jpg, gif, png, bmp and jpeg files. These .htaccess codes will generate a 403 Forbidden Error when your hotlinked image is checked from some outside websites.

Enable HotLink Protection using .htaccess

Also, you can choose to replace the 403 error page to a specific webpage with the following code. Note that you’d better make sure that the link of that page is not hotlink protected, and your web server can navigate an endless loop for that link.

Enable HotLink Protection using .htaccess with Locked Webpages

Here, we’d like to introduce an editing tool for the creation of .htaccess tool. With it, you only need to enter the domains that can use all your images, allow the blank referrers, decide the file types to protect and click the Generate .htaccess File button. Then, the required coding stuff can be created automatically without any error. To use the tool, you can check this page.

Enable HotLink Protection using Plugin

If you do not have the cPanel control panel and are not willing to use the coding stuff, you can resort to the utilization of plugins for enabling the HotLink Protection. Note that the following plugins are worked for WordPress powered websites.

HotLink Protection

This is a single-step plugin for the prevention of hotlinking. Upon the successful installation, you do not need to do any configurations as it automatically adds an .htaccess file to the root folder of your website, containing the coding stuff that can stop any outside websites from linking directly to your images or files. However, this plugin can only work for your main domain but not your sub-domains and add-on domains.


This is an extensive WordPress plugin that fights against hotlinking issues, resulting in the overuse of bandwidth, slowing down of page loading, and the decrease of traffic. Besides, it has a watermark function that adds the watermarks on your images to prevent others from stealing your images effectively. From its setting page, you can decide the watermark position and transparency, file types to be protected, domains you allow to hotlink images and some other optional settings freely.

Special Notes

It is true that HotLink Protection is a valuable service to keep your website safe. However, it also has a major drawback as it can be a resource drain. Once it is enabled, your web server has to check whether the content request is for the protected file types and whether the referring URL is allowed. This may affect the page loading speed of your site to some extent.

Therefore, when considering whether to enable this feature, you can think about your website type and size. Personally speaking, if you are running a large and business-alike site, then it is worth enabling HotLink Protection. However, if your site is a small and personal one, you can simply ignore this practice.