Enable Hotlink Protection


Enable Hotlink Protection

Hot link protection is security measure inorder to prevents other websites from directly linking to files and pictures on your website. Other sites will only be able to link to file types that you don't specify.

Hotlink Protection – Preventing Bandwidth Theft
Bandwidth theft or hotlinking is direct linking to a web site's files such as images,vedios etc, this will result to high bandwidth consumption. For example some would be using an <img> tag to display a JPEG image on his website which is used in your own site. 

Lets check how to enable Hotlink Protection.

Enable Hotlink protection for an account.

Through cPanel
1.Login to Cpanel.
2.Select Hotlink Protection under the Security tab.

You will be redirected to the following page.

3.Click on Enable button. Then the hotlink protection will be enabled for that particular domain.
4.Now in the URLs to allow access: box Enter the URL to any domain you wish to allow hotlinking.
5.Provide the extensions in the Block direct access for these extension box.
6.In the Redirect request to this URL: you can enter a URL that anyone trying to hotlink will see in the place of image, etc.
7.Click on Submit button.




Through Backend
1.Go to users account
#cd ~user/public_html
#pwd
/home/user/public_html

2.Create .htaccess file here and enter the following entries
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$ 
RewriteCond %{REQUEST_FILENAME} -f 
RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g?|png)$ [NC] 
RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?domain\. [NC]
RewriteRule \.(gif|jpe?g?|png)$ - [F,NC,L] 
</ifModule>
For example:-

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://www.yourdomain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.yourdomain.com$ [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp|swf)$ http://www.yourdomain.com/nohotlinking.jpe [R,NC]
</ifModule>

Enable Hotlink Protection by default for new accounts

It possible to make hotlink available by default for new account.

Please Note
For enabling this the client should owns a dedicated server.

For enabling Hotlink Protection by default for new accounts, you can follow below mentioned steps:

#cd /root/cpanel3-skel/public_html/
#pwd
/root/cpanel3-skel/public_html/
 
#vi .htaccess
 
=====================================
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://{HTTP_HOST}/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://{HTTP_HOST} $ [NC]
</ifModule>
=====================================

No comments: