Prevent Image Hotlinking on WordPress

A guide explaining how you can enable image hotlinking protection in WordPress by editing the .htaccess file.

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\.)? [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)? [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ [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. ‘’ to view and use the images
  • Line 4: Allows your another site, i.e. ‘’ 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

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!