How To Block Referrers And Disallow Hotlinking And Downloads From External Websites
Hotlinking (direct linking to a web site’s files - images, video, etc.) and downloads from external websites without your permission is an obvious bandwidth theft. If a webmaster or a website owner wants to disallow or restrict the downloads of downloadable items on his/her website through other websites other than his’/her’s; I mean, if a visitor wants to download items in mydomain . com, of course you want to execute that action through mydomain . com website only and NOT through other website that make a link to the downloadable items in your website. You can do that by blocking referrers.
In your download folders where you compiled your downloadable items, create a .htaccess file and paste the code below. This code basically blocked external websites referrers other than your own website;
SetEnvIfNoCase Referer “^http://(www.)?jcmiras.net” spam_ref=1
<FilesMatch “(.*)”>
order deny,allow
deny from all
Allow from env=spam_ref
<FilesMatch “(.*)”>
Where jcmiras.net is the only domain allowed to link and execute the download.
You can also use the code below for disabling hotlinking. However, in this code, you have to specify the extensions of the files that you don’t want to be hotlinked. This may not work on html pages.
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yourdomain.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ - [NC,F,L]
Where yourdomain is the allowed website to hotlink (it should be your own domain) and jpg|jpeg|png|gif are the protected file types.
Filed in: 










