How to Prevent Hotlinking in WordPress Easily (6 Ways)

Hotlinking adversely affects your websites. It eats out your bandwidth and has negative impacts on your website performance. This is one of the common illegal steps bad people usually take to save their bandwidth by eating out others’. Once this has happened to your case, you might as well take the necessary steps to prevent this. Today, we will talk about how to stop image hotlinking on WordPress sites.

It’s better to take measures beforehand so that no one can do this to your website images. You can prevent image hotlinking in WordPress sites in some easy ways. First, let’s know what this really is.

What is Hotlinking?

Hotlinking is using someone else’s images on your website by using that particular image URL. It means images will be shown on your site but they will be served from somewhere else. When you open an image on a new tab it shows the image URL. Hotlinkers use that URL to save their bandwidth and load time. Hotlinking is a very bad practice. Any changes to the image URL will affect the display of that image.

Why Should You Prevent Image Hotlinking?

If you care about your website performance, you should prevent hotlinking of your website images or any other media resources you have. While using someone else’s images without proper permission is bad, the hotlinking, in this case, is way worse than that. 

  • Hotlinking eats your bandwidth and will cost you extra money because it costs money to host media resources. 
  • Image hotlinking in most of the cases is illegal. People may permit you to use their images but they generally don’t allow you to use their bandwidth.
  • It’s a huge drain on your resources. You may go through an unexpected number of queries in a short time.

It’s highly recommended that you don’t hotlink other people’s resources and don’t let them do this to your website.

How to Check if Someone is Hotlinking Your Website Images

Hotlinking in WordPress

Generally, you don’t have an option to understand whether someone is hotlinking your website images. This is why it is wise to prevent this beforehand. When you care about it and want to know if someone is hotlinking your website images, enter the following command in Google search bar and click on Images.

inurl:yourwebsite.com -site:yourwebsite.com

For example, to check whether someone is doing this to Virfice.com’s images, it would be:

inurl:virfice.com -site:virfice.com

The Google search result will display hot-linked images and the website URLs that are using those images.

How to Prevent Hotlinking in WordPress Sites

There are several ways to prevent hotlinking in WordPress sites. Go through the processes below and follow the one you prefer. We will show you 6 different methods to do this.

Method 1: Prevent Hotlinking Using CDN

Fortunately, preventing image hotlinking in WordPress sites is easy. You can use a CDN with hotlinking protection. As some CDN providers like Cloudflare and KeyCDN, you will have this option inside.

Method 2: Enable Hotlink Protection in cPanel

You can also prevent hotlinking from your cPanel settings. If your hosting providers use cPanel to administer servers on the client’s end, you can enable hotlink protection there easily.

First, you have to log in to your hosting account. Then, you can scroll down to the Security Area and click on the Hotlink Protection option. 

You are redirected to the setup screen. Click on “Enable” and configure the settings. Finally, save the changes by clicking on the “Submit” button. 

Method 3: Prevent Image Hotlinking in Server

You can simply enable WordPress hotlinking protection in the webserver by pasting some sorts of the code snippets. If your server is running on Apache, paste the following code in your .htaccess file. 

 RewriteEngine on
 RewriteCond %{HTTP_REFERER} !^$
 RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yourdomain.com [NC]
 RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.com [NC]
 RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?bing.com [NC]
 RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yahoo.com [NC]
 RewriteRule \.(jpg|jpeg|png|gif)$ - [F]

In this code, you need to change yourdomain.com to your website. So, access your .htaccess file and paste the code there to prevent image hotlinking in your WordPress site.

If your site in on the NGINX server, paste the code below in the NGINX config file.

  location ~ .(gif|png|jpeg|jpg|svg)$ {
      valid_referers none blocked ~.google. ~.bing. ~.yahoo. yourdomain.com *.yourdomain.com;
      if ($invalid_referer) {
         return   403;
     }
 }

Method 4: Prevent Hotlinking With a WordPress Plugin

A comprehensive and easy to use WordPress security plugin All In One WP Security & Firewall has a built-in system inside to prevent image hotlinking. You better install the plugin and enable hotlinking protection in the setting. Apart from that, it helps to add some extra security and firewall to your WordPress site. The plugin is quite popular with 800,000+ active installs and 800+ 5 stars reviews. Let’s see how to enable hotlinking protection with this plugin.

Step 1: Install and Activate All In One WP Security & Firewall Plugin

Log in to your site and go to your dashboard. Install and activate All In One WP Security & Firewall plugin just like the way you install any other plugin in WordPress.

Step 2: Configure the Firewall Settings

Once you have installed and activated the plugin, you have to configure its firewall settings. FInd WP Security and go to Firewall > Prevent Hotlinks. Check mark on  “Check this if you want to prevent hotlinking to images on your site.” option at the bottom. Click on “Save Settings” to apply the changes.

Method 5: Renaming Image File Names

You can easily prevent hotlinking by renaming image files. For this, you need to know the hot-linked images first. Search hot-linked images on Google as shown in this tutorial above, then rename the image files. This will work for the images that have been hot-linked already. But it will not guarantee the possibility of hotlinking further.

Method 6: Use Watermark of Logo or Brand Name on Your Images

You can use Watermarks on your website images. This will discourage people to hotlink your images. Watermark identifies your images no matter where they are being used. Having your website name on your images will help you prevent image hotlinking eventually. You can also put your brand name somewhere on your images.

Protecting your website resource from theft is your responsibility. As there are bad people out there to copy your content, use your resources, and eat out your server space. You should take measures to safeguard your website from them. Preventing image hotlinking is one of the effective ways to stop the misuse of your bandwidth. I hope this article helps you save your bandwidth in WordPress sites.

Amie Suzan
Amie Suzan

As a seasoned WordPress technical writer with five years of experience, I am passionate about WordPress and web development. I also enjoy traveling, particularly solo trips, which allow me to explore new places and gain fresh perspectives.

Articles: 85

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

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