Whenever you want to ban/prevent hotlinking your media files and protect your server’s resources and bandwidth you may use the following snippet in the .htaccess file of your main directory of your site.
1 2 3 4 5 6 7 8 |
# BEGIN Hotlinking Protection RewriteEngine On RewriteBase / RewriteCond %{HTTP_REFERER} !^http(s)?://(www.)?<strong>YOURSITE.YOURDOMAIN</strong> [NC] RewriteRule .(webm|3g2|3gp|3gpp|flv|m3a|m4a|m4b|mka|mkv|mov|mp2|mp3|mp4|mpeg|swf|wav|wma|wmv|<strong>XYZ</strong>)$ – [NC,F,L] # END Hotlinking Protection |
Just replace YOURSITE.YOURDOMAIN with your site and at the fourth row of the actual code (don’t mind the # comment line) you can put whatever file extensions in the brackets () separated by | sign – (X|Y|Z).
How it works?
Well, it just tells the server to ban all third parties from accessing your data so only your site can display that info and that’s it.
PS: If you are a WordPress user and you don’t want to mess with any code this plugin is for you : )
Enjoy