Steps to enable Hotlink protection by default

Tags: .htaccesscPanelhotlink

Published on: July 30, 2014 by Ajo

Steps to enable Hotlink protection by default



Hot link protection is security measure in order to prevent 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.Let us see how to enable Hotlink protection

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


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]

For example:-

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^*$ [NC]
RewriteCond %{HTTP_REFERER} !^$ [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp|swf)$ [R,NC]

Enable Hotlink Protection by default for new accounts

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

#cd /root/cpanel3-skel/public_html/

Then create the .htaccess file with the following data

#vi .htaccess

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://{HTTP_HOST}/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://{HTTP_HOST} $ [NC]


Category : cPanel, Howtos, Linux



You may also read:


Add new commentSIGN IN

Let's Connect


Your Cart

Cart is empty.

Send this to a friend