Block Content Theft via URL Masking
There are ways to grab content from the internet and publish it at a different URL without revealing where the content was obtained.
There are legitimate reasons for masking URLs of content — your own or another's content published with permission. However, there are those those who attempt to grab content illegitimately using URL masking.
This article describes how to prevent one common technique to block content theft and links to a Kindle book containing instructions for blocking another common technique.:
-
With web page retrieval software —
How to block the publishing of content obtained by software running at a different web site.
Preventing Content Theft with Page Retrieval Software
Grabbing a page from the internet and displaying it with a different URL in the browser's address bar is easy with both PHP and Perl CGI software.
Blocking those is easy, too.
Here is the JavaScript:
<script type="text/javascript"> var domain = "example.com"; var redirect = "http://example.com/page.html"; if( (location.hostname != domain) && (location.hostname != "www."+domain) ) { location.href = redirect; } </script>
On the second line of the above code, replace example.com with the domain name of the web page to be protected. Just the domain name, not including http:// or www.
On the third line of the above code, replace http://example.com/page.html with the URL of the web page being protected.
Put the JavaScript somewhere in the web page. The higher in the source code the JavaScript is at, the sooner it will kick in.
If yours is a PHP web page, both the domain name and the URL of the web page being protected can be inserted automatically, which lets you put the JavaScript into a template. Here's the code (color coding maintained):
<script type="text/javascript"> var domain = "<?php echo(preg_replace('/^www\./','',$_SERVER['HTTP_HOST'])); ?>"; var redirect = "<?php echo(((isset($_SERVER['HTTPS']) and preg_match('/^on|true|1$/i',$_SERVER['HTTPS']) )?'https://':'http://').$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']); ?>"; if( (location.hostname != domain) && (location.hostname != "www."+domain) ) { location.href = redirect; } </script>
Will Bontrager