Get FAST WordPress Support
World’s Fastest WordPress Support Since 2009  
How To Prevent Image Hotlinking In WordPress

How to Prevent Image Hotlinking in WordPress

Need to stop image hotlinking in WordPress?

A few things could slow down your site as quickly as image hotlinking. The phenomenon suggests displaying an image on a website by linking to another website to obtain the source data of the picture each time it is needed, rather than saving a copy of it on the website on which the image will be shown.

Such a practice has multiple consequences, which makes it one of the biggest threats to website performance and stability. As a serious webmaster, you should learn how to deal with this issue. Our post will show you how to prevent image hotlinking in WordPress.

Why Image Hotlinking in WordPress Matters?

WordPress powers around 30% of the entire Internet, reaching almost 60% of the global content management system (CMS) market. This means the majority of hotlinking attempts occur in WordPress, so we will focus on this CMS.

But before we do, we need to explain why image hotlinking matters anyway. There are several reasons to avoid it, with the most important being these:

  • Website performance: When a website hotlinks to your images, they are still loading from your server even though users don’t visit your website at all. Stealing your bandwidth, other webmasters essentially slow down your website and jeopardize performance.
  • Money waste: If a hotlinking problem comes from a popular website, it will burden your own server drastically. You will probably have to pay for additional server capacity in order to recover your website as soon as possible.
  • Laziness: Webmasters who don’t create their own images simply prove they are lazy. Content creators at Bidforwriting say that it’s never a good sign because users learn sooner or later that the content is not authentic, so the website loses traffic in the long run.
  • It’s illegal: Image hotlinking is not only immoral but also illegal in most cases due to copyright regulations.

How to Recognize Image Hotlinking in WordPress

Poor website performance is the primary indicator of image hotlinking. However, this problem may occur for a number of reasons, and you can hardly guess the real cause unless you conduct research. The easiest way to do it is by using Google Images.

You only need to enter a simple line of code to obtain results for all images on your website:

The search engine will display results that include only images not containing your website’s URL, so you can easily detect hotlinking. After that, the only thing left to do is to eliminate hotlinking attempts.

How to Stop Image Hotlinking in WordPress

There are multiple ways to activate hotlink protection on your website. Most solutions are automatic, but we will also explain how to solve the problem manually. Let’s see the most common procedures:

CDN with Hotlink Protection

CDN providers are comprehensive website management tools that include pre-built image hotlinking protection. It’s a quality solution because CDN can distinguish between intruders and bots that are really supposed to hotlink to your content. Besides that, CDN does not require any kind of WordPress coding intervention, thus keeping your site safe and sound.

NGINX Hotlink Solution

Some websites are running on NGINX, an open source server that demands only a small-scale change of code to prevent hotlinking. It is done in the config file by adding this line of code:

location ~ .(gif|png|jpeg|jpg|svg)$ {
     valid_referers none blocked *;
     if ($invalid_referer) {
        return   403;

Use WordPress Plugins

With more 55 thousand plugins currently available, it is reasonable to assume that WordPress also offers a number of anti-hotlinking tools. Some plugins are strictly hotlink-oriented, but most of them have poor user reviews and don’t update frequently.

For this reason, we believe the best solution is to utilize more comprehensive security plugins that offer pre-built hotlinking measures. A tool like this will prevent image hotlinking while taking care of other security-related details as well.

Edit the .htaccess File Manually

As we already mentioned, you can always choose to prevent image hotlinking manually. It’s not too complicated, while it gives you substantial advantages in terms of website performance. Webmasters edit the .htaccess file to block or white-list individual websites and referrers, protect files, and display custom images detecting image hotlinking.

As for the hotlink prevention, your job is to enter the .htaccess file and add the following lines:

RewriteEngine on

RewriteCond %{HTTP_REFERER} !^$

RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)? [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)? [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ [NC,R,L]

Now you need to learn what each line of code actually means. Here’s an explanation:

  • Line 1 activates the rewrite engine that enables redirecting.
  • Line 2 allows users with firewall protection, aka blank referrers, to see the image.
  • Line 3 grants permission to ‘’ to view the images. However, you need to change ‘’ and replace it with the real domain name of your site without using the www.
  • Line 4 grants permission to another website to see and use your photos. In this case, you need to replace ‘’ with the actual domain name of this website.
  • Line 5 suspends image hotlinks and redirects users to the Imgur photo gallery. Besides that, you can add a different, customized image instead of this one if it suits your website’s needs more appropriately.

As you can see, manual image hotlinking prevention is not a complex procedure. You just need to be careful to avoid damaging other WordPress code lines, but that’s highly unlikely. And if you still think this is too tricky for you to handle, just go back to one of the solutions we mentioned above and use it to protect the performance of your site.

Conclusion – Image Hotlinking in WordPress

Image hotlinking is unethical and unprofessional digital practice, but that doesn’t stop many webmasters from doing it. If you want to avoid the consequences of such an annoying phenomenon, you need to understand how it works and what to do against it.

In this article, we showed you how to prevent image hotlinking in WordPress. Make sure to remember our tips and you won’t have to worry about hotlinking ever again. It won’t only save you a lot of time, but also improve website performance and user satisfaction.

Leave a Reply

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