Prevent Image Hotlinking on WordPress

2 minutes read

It’s so common on the internet to have your content stolen. People often scrape your entire hard-worked content and put it over on their sites. That includes image hotlinking too, when the images hosted on the web server paid by you, being used by someone else.

If you use WordPress to publish your content, you can easily enable image hotlinking protection on your WordPress-powered site. This post is all about guiding you to protect your images from being stolen like that.

What the heck is Image Hotlinking?

Let us assume you have a cool site abc.tld, and have so many cool articles there accompanied by lots of cool images. Then there comes someone from xyz.tld and copies an image abc.tld/image.jpg from your website, and puts it on his site. This would be called image hotlinking.

Why is it considered bad?

It’s bad as someone else will be using your creation (the image) under their name as well as your resources (the bandwidth consumed to display the image each time the site using it will be requested). And I’m pretty sure you too won’t be liking it!

Tweaking .htaccess for hotlinking protectoin

This one is perhaps the best way to enable hotlinking protection on WordPress-based sites. You just have to edit the .htaccess file, add the following code at the end of it, and save:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?your-goood-site.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?your-other-good-site.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ http://i.imgur.com/g7ptdBB.png [NC,R,L]

That’s it!

What the above code will do

Well, explaining line-by-line:

  • Line 1: Opens the redirection process
  • Line 2: Allows blank referrers (search engines, browsers, hosts, proxies, and people requesting your images by typing it in the address bar or requesting through bookmarks) to view the image
  • Line 3: Allows your own site, i.e. ‘your-good-site.com’ to view and use the images
  • Line 4: Allows your another site, i.e. ‘your-other-domain.com’ to view and use the images (optional, remove this line if doesn’t apply)
  • Line 5: Replaces all of the images from your site onto some other site with http://i.imgur.com/g7ptdBB.png

Fair enough, I guess.

WordPress Plugins for Image Hotlinking protection

If you are not into coding, and finding it troublesome to edit the .htacces, you may then install take help of the below mentioned plugins:

  1. WP PicSheild Hotlink defense, although not being updated regularly.
  2. All in One WP Security & Firewall, image hotlinking protection is one of the features provided by this one along with a number of security tweaking options

If you know a better WordPress plugin to protect images, feel free to add a comment and tell us about it. Thanks in advance!

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

Related Posts:

WordPress featured thumbnails allow you to add a featured image to your posts. If your WordPress theme has this functionality, then you may set a featured thumbnail to your post by using the Featured Image meta box by clicking the Set Featured image link and u...
To upload images into a MySQL database, you'll need to follow a few steps:Create a table: Begin by creating a table in your MySQL database that will store the images. The table should have columns to hold the image data, such as an 'id' (primary ke...
To set category images in WordPress, you can follow these steps:Log in to your WordPress dashboard.Navigate to the "Posts" section and click on "Categories".Find the category for which you want to set an image and click on "Edit".On the...