How to avoid stealing website contents using .htaccess
Posted: Thu Apr 15, 2010 2:14 am
If you have noticed someone using iframe to use your website on their domain. There is a way to block anyone from linking to your website contents illegally, you can block all sort of files jpg, html, php, flash, videos, mp3 and so on. After this, stealer will get a Forbidden 500 error.
To prevent all sorts of hotlinking, you can use the following code.
Change yourdomain.com with your domain name. This will redirect visitors to your homepage.
Code: Select all
RewriteEngine On
RewriteCond %{HTTP_REFERER} website1.com [OR,NC]
RewriteCond %{HTTP_REFERER} website2.net [OR,NC]
RewriteCond %{HTTP_REFERER} website3.co.cc [NC]
RewriteRule .*.(gif|jpg|swf|png|html|php|asp|xml|htm)$ - [NC,F]
Code: Select all
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yourdomain.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ - [NC,F,L]