Adding this snippet into your .htaccess file, you will be able to add hotlink protection to your files. It will help you to save your site bandwidth.
RewriteCond %{HTTP_REFERER} !^http://example.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://example.com$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.example.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.example.com$ [NC] RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC]
Here hotlink has been added to image files (.jpg, .jpeg, .gif, .png, .bmp). You can add or remove more file types.
RewriteCond %{HTTP_REFERER} !^http://example.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://example.com$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.example.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.example.com$ [NC] RewriteRule .*\.(jpg|jpeg|gif|png|bmp|zip)$ - [F,NC]
Remember to replace “example.com” with your domain name. Look at the example below: