Javascript protection from site cloning

I will here show a tiny bit of javascript that can help you if implemented AFTER you’ve been cloned, mostly used in cases when your ranks and traffic has fallen down so much that you’re trying to save what can be saved, and get a portion of your traffic back from the clone.

Both of the javascripts I’ll be listing are, simply said, checking if your site really is your site and then doing a redirect to your original site.

Javascript cloning protection version one

This piece of javascript needs to be put in a separate .js javascript file and hosted remotely (on some other website). Give it some name, example hello-hacker.js

if(!location.hostname.match(/(^|\.)YOURDOMAIN.com$/)){
/* Redirect the person as an example. */
window.location=”http://www.YOURDOMAIN.com/”;
}

Upload it to other site and add it to your site, somewhere between <head> and </head> tags in the code. Like this:

<script src=”http://www.some-other-site.com/hello-hacker.js”></script>

 

Javascript cloning protection version two

This piece of script is identical to previous one, but as you can see from the code, it combines your domain name from two factors, so that your domain name can’t be spoofed automatically by the clone site. You can include this javascript directly in your website.

<script>
if(window.location.href.indexOf("yourd"+"omain.com") < 0) {
       window.location("http://yourd"+"omain.com"); 
}
</script>

 This will not help much

I’m not writing too much detail in this article because it doesn’t make much sense, as this method is pretty much worthless. So to say, this is like nursing the symptoms, without finding the cure to the disease itself. Another problem with this javascript is that hackers can block your javascript from the clone in a minute, and simply keep cloning your site without any issue.

I will cover the clone website shutdown in my next post.

Leave a Reply