htaccess prevent hotlinking

13.Jul.2010

If you have problems with other websites stealing your bandwidth, and you want to prevent hotlinking, use following snippet and place code in your htaccess file:

1
2
3
4
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+.)?my-website-url.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*.(jpg|gif|bmp|png)$ http://hotlink.my-website-url.com/hotlinking-is-not-allowed.jpg [L]