htaccess

How to enable hotlink protection using .htaccess Code

When an outsider tries to insert any content from your site into another competitor website and eventually consumes your site bandwidth to serve their files, this unethical breach is known as a Hotlink. The Hotlink Protection interface helps in preventing this issue.

Hotlink Protection means protection of your static files from being linked directly. By enabling hotlink protection one can save server bandwidth. .htaccess is being widely used to tweak configuration settings of Apache Web Servers. It can also be used to enable hotlink protection of your Website. Let’s learn how to do it using .htaccess.

How to enable hotlink protection using .htaccess

STEP 1: Open your .htaccess on an editor. Add the below codes in it.

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^https://(.+\.)?yourwebsite\.com/[NC]
RewriteCond %{HTTP_REFERER}!^$
RewriteRule .*\.(jpg|jpeg|gif|bmp|png|swf)$-[F]

Please Note that:

When you click Disable, the system deletes the entries in the List the URLs. This is the list to which you want to allow access. Thus, we strongly recommend that you save the list locally first before you disable hotlink protection altogether.

Replace yourwebsite.com with the original domain name. Check whether your files can be hotlinked or not.


We hope this tutorial helps you find the perfect solution. If your like our tutorials, definitely you’ll love our support. All VernalWeb hosting plans include 24/7 support from our amazing inhouse support staff. Check out our web hosting plans and have your website migrated today!


Posted

in

by

Comments

Leave a Reply