content top
Protect your Blog Content from Hotlinking

Protect your Blog Content from Hotlinking

If I like a video or an Image on your site and show them on my site by a link then it will be hotlinking. For example you have a very interesting video tutorial on your site and I have decided to share that video with my site visitors. So I will be hotlinking your video on my site and anyone from my site views the video will be using your bandwidth and if I have a fair amount of daily visitors, your server might crash for this extra load. Just imagine couple of high traffic site hotlinking to display your video or image on their sites, depending on your hosting plan it could potentially eat up all your bandwidth pretty quickly. My host server crashes without a fail if I get more than three thousand visitors a day.

If your site features any content – images, videos, music, etc. – that you want to protect from hotlinkers, there are a number of different methods that you can apply. The easiest and most effective anti-hotlink method can be achieved via HTAccess:

 

# always save a backup copy of your .htaccess file. Save it as .htaccess2 for example so if you run into problems, you can upload your backup copy to the server again. .htaccess file is in the main WordPress directory.

 

<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>

 

Only thing you need to change in the above code is “domain” with your actual domain URL. Above code is set to protect the following file types: .jpg, .jpeg, .jpe, .gif, and .png. If you want to protect additional file types for example .avi then simply add the file type in line 5 and 6 with a vertical line.

 

RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g?|png|avi)$ [NC]

RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?domain\. [NC]

RewriteRule \.(gif|jpe?g?|png|avi)$ – [F,NC,L]

 

Tags

Related posts

Leave a Reply