Prevent image hotlinking with .htaccess in wordpress – Hotlink protection

How to prevent image hotlinking in wordpress with .htaccess - Hotlink protectionAre you concerned about people stealing images from your website? We are not asking about people who copy images, we are talking about image hotlinking.  Content scrapers – Yes, spammers and especially people who are new to blogging think about creating a shorter way to success and just plagiarize content from various websites. In short they are just lazy peoples who steal content from source code and just re-blog it. They are not just plagiarizing your work; they are utilizing and draining your precious bandwidth. You must take note on this article in order to stop bandwidth theft and to prevent image hotlinking in your website. Here we will see how to prevent image hotlinking and bandwidth theft in wordpress.

What is image hotlinking?

A practice of linking and displaying images directly from your site to their website is known as image hotlinking. Instead of hosting images in their own server, they link images that are hosted in your website. In other words it is known as leaching, direct linking and offsite image grabs.

Mostly content scrapers (fools) rely on your site thus stealing images and sucking your server bandwidth. The image is loaded from your server each time when someone visits the website that is hotlinking. You are losing your bandwidth and moreover your site gets slow which annoys you much. Using this tutorial you can easily prevent image hotlinking and bandwidth theft in your wordpress site.

Recently here at Blog Time Now we spotted a blog who scraping content and hotlinking images from us regularly. So we decided to remove all those images and replace all images with the one below.

How to prevent image hotlinking and bandwidth theft with .htaccess in wordpress

If you are running a photography blog then preventing your site from image hotlinking is a must. By using .htaccess you can prevent image hotlinking just like we did. The image below is the site that scraps content and calls images from our site. The interesting part is that they never know about image hotlink protection until they visit that particular page. Chances are less because they are busy copying content from various other websites. You might be the next, so take action in advance.

How to prevent image hotlinking and bandwidth protection in wordpress

How to prevent image hotlinking and bandwidth theft in wordpress

If you are running wordpress in Linux servers then you will have a file named .htaccess. You can find .htaccess file in your wordpress root directory that is where files like index.php and wp-config.php are located. Sites that are not powered by wordpress can create an .htaccess file and upload it to your website.

Backup your wordpress files before editing your .htaccess file. Now copy, paste the following code in .htaccess.

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mysite1\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mysite2\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mysite3\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$
  1. In the above code the first line starts the rewrite.
  2. In second, third and fourth lines enter your site and other site names without WWW that are allowed to hotlink your images. You can additionally add lines and if your site is other than .com then replace .com with .org or .us. (example: (.+\.)?blogtimenow\.com [NC])
  3. The fifth line allows images for empty / blank referrals.
  4.  The last line is where you replace your entire images with an default image. The supported file formats are jpeg, jpg, gif, bmp and png and this will show up when someone hotlink your images.

Hotlink protection using wordpress plugin

If you don’t like to go manual with coding, then just install and activate plugin. Here are two plugins for you to prevent from image hotlinking and bandwidth theft.

Hotlink Protection – Just install and activate hotlink protection and prevent others from stealing your images. This plugin does the entire manual step that we mentioned above that is adding .htaccess file and preventing hotlinks.

REC WP-PIC shield – This plugin is all you need if you sell graphics, icons and photos in your website. An best wordpress hotlink protection plugin with more options.

Hope this post helped you on how to prevent image hotlinking and bandwidth theft in wordpress site. Please share it and if you have any questions then feel free to leave your comments below. Subscribe to our RSS feeds.