What is Hotlinking? How to do image protection from .htaccess

What is hotlinking? In my knowledge, very few bloggers know about Hotlinking. When someone copies the content of your post or just an image and pastes it on their blog, it opens with the URL of your site and loads from your server. This is called Hotlinking in technical parlance. This not only bothers you with copy-pasting, but it also bothers you with web hosting bandwidth.


What is Hotlinking How to do image protection from htaccess


Most people copy our article directly in which all the images used are loaded from our hosting server and therefore your web hosting bandwidth is wasted.


What is Hotlinking?


For new people, when someone steals an image of your website and uses it on their site, and when someone opens their site, that image is loaded on your own hosting server, this is called hotlinking in the technical language.


In simple words, the process of copying your image from something and adding it to your site and using your web hosting bandwidth is called image hotlinking.


Every time a user opens their site, the image will be loaded from your server. This is called image hotlinking. It is of no use to you. The only disadvantage is that a toggler steals the image of your site and your server from above. Take advantage, you can block hotlinking with .htaccess function if you want.


How To Prevent Image Hotlinking Using .htaccess to WordPress


In your WordPress blog, you can protect the image hotlink with the help of the .htaccess function. For this, you need to add code in the .htaccess function.


On WordPress, you can redirect to the site with allow block referral links and protect the site by using .htaccess. All you have to do is activate it on your hosting panel with an .htaccess name.


For this you can go to your hosting cPanel >> File Manager >> public_html option or you can use Yoast SEO plugin then go to WordPress dashboard >> SEO>> Tools >> File editor and open the .htaccess file.

Now you need to add this code to the .htaccess file.


RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yoursite.com [NC] RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?youranothersite.com [NC] RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?youranothersite.com [NC] RewriteRule \.(jpg|jpeg|png|gif)$ https://i.imgur.com/removed.png [NC,R,L]


In this, you have to add 3-2 specific websites. I mean, the image will be shown only on the URL of the site where you add it. Your image will not be shown on other sites. Here you have to add the URL of your site and some other sites on which. You can use the image of this site. I have colored it red


How to use Code in .htaccess file to Protect Hotlinks?


If you do not understand how to use the above code in .htaccess function then let me tell you about it in detail. Tell me above. There are total 6 lines in the code.


1. RewriteEngine on


This code is for activating and ordering .htaccess if your blog already has a .htaccess function then this line will already be added to the function and you don’t need to add this line again and if you do it the first time. If you are editing the .htaccess file, you must add this line.


2. RewriteCond %{HTTP_REFERER} !^$


This line alerts the bank referrer so that only the site link you add here will show the image.


3. RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yoursite.com [NC] 4. RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?youranothersite.com [NC] 5. RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?youranothersite.com [NC]


In three, four, five lines, you have to add the sites on which you want to show the image. First, you have to add the link to your site. You can also add sites.


.6. RewriteRule \.(jpg|jpeg|png|gif)$ https://i.imgur.com/removed.png [NC,R,L]


You must add an error image to the sixth line. I mean when someone uses the link of your site image you won’t see any image there. For this, you should not use the image of your site, but use a link to an error page.

Finally, now you understand everything. For example, you can see the Hotlinking Protection Code of my WordPress blog.


How to use code in .htaccess file to protect hot link?

This way you can change the domain from this link to block hotlinking and protect your site. After adding the code to the .htaccess the file and check if your site is working properly.



Leave A Reply

Your email address will not be published.