How to avoid stealing website contents using .htaccess

Web programming topics
Post Reply
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

How to avoid stealing website contents using .htaccess

Post by Neo » 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.

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] 
To prevent all sorts of hotlinking, you can use the following code.

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]
Change yourdomain.com with your domain name. This will redirect visitors to your homepage.
Pansophic
Sergeant
Sergeant
Posts: 25
Joined: Sun Feb 13, 2011 4:05 pm

Re: How to avoid stealing website contents using .htaccess

Post by Pansophic » Tue Mar 01, 2011 3:34 pm

pretty helpful tut over there, thanks for posting this here bro.
User avatar
SemiconductorCat
Major
Major
Posts: 455
Joined: Mon Aug 22, 2011 8:42 pm
Location: currently in hyperspace

Re: How to avoid stealing website contents using .htaccess

Post by SemiconductorCat » Mon Jan 30, 2012 9:12 am

you still can alter the http headers and made a ajax request if you can execute javascript on your
site code. Then you could read the html code of the site to the javascript variable, then prase the
reference links and fix them.

Do you still believe evil people outside your localhost are not smarter to write that kind of script for you?
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: How to avoid stealing website contents using .htaccess

Post by Neo » Mon Jan 30, 2012 4:32 pm

A .htaccess (hypertext access) file is a directory-level configuration file supported by several web servers, that allows for decentralized management of web server configuration.

The original purpose of .htaccess - reflected in its name - was to allow per-directory access control, by for example requiring a password to access the content. Nowadays however, the .htaccess files can override many other configuration settings including content type and character set, CGI handlers, etc.

These files are placed inside the web tree, and are able to override a subset of the server's global configuration for that directory, and all sub-directories.

Sandun, can you now understand that you are talking about completely a different subject. Please please read carefully before making comments. You are an intelligent fellow, so you need to show up your knowledge with perfect understanding on the problem rather just being quick to fill up the forum.
Post Reply

Return to “Web programming”