Bandwidth theft or “hotlinking” is direct linking to a web site’s files (images, video, etc.)
Hotlinking (the act of using images from another site than yours) is unfortunely a common practice which can waste lots of your precious bandwidth. This useful snippets will redirect all hotlinked images to a specific image, defined on line 6.
RewriteEngine On #Replace ?mysite.com/ with your blog url RewriteCond %{HTTP_REFERER} !^http://(.+.)?mysite.com/ [NC] RewriteCond %{HTTP_REFERER} !^$ #Replace /images/nohotlink.jpg with your "don't hotlink" image url RewriteRule .*.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpg [L]
this code will work great, but i have a doubt,,, i have a subdomain,,, do this work for subdomain?? and also where i want to place this htaccess file for subdomain
Hi Asho..
below code is used to prevent hotlinking for all domain and subdomain too..
RewriteEngine On
#Replace ?mysite.com/ with your blog url
RewriteCond %{HTTP_REFERER} !^http://(.+.)?mysite.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.+.)?subdomain.mysite.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
#Replace /images/nohotlink.jpg with your “don’t hotlink” image url
RewriteRule .*.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpg [L]
The .htaccess file can be placed on any folder on your site. It has recursive effect. This means that if you place the .htaccess file in your web root (the main folder of your web site) the directives and commands you place in the .htaccess file will have effect on all sub-folders.
If you place a .htaccess file in a sub-folder, its directives will override the ones that you have in your site main folder.
Thanks
this code will work great, but i have a doubt,,, i have a subdomain,,, do this work for subdomain?? and also where i want to place this htaccess file for subdomain
Hi Asho..
below code is used to prevent hotlinking for all domain and subdomain too..
RewriteEngine On
#Replace ?mysite.com/ with your blog url
RewriteCond %{HTTP_REFERER} !^http://(.+.)?mysite.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.+.)?subdomain.mysite.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
#Replace /images/nohotlink.jpg with your “don’t hotlink” image url
RewriteRule .*.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpg [L]
The .htaccess file can be placed on any folder on your site. It has recursive effect. This means that if you place the .htaccess file in your web root (the main folder of your web site) the directives and commands you place in the .htaccess file will have effect on all sub-folders.
If you place a .htaccess file in a sub-folder, its directives will override the ones that you have in your site main folder.
Thanks