Software, your way.
burger menu icon
WillMaster

WillMaster > LibrarySecurity and Blocking

FREE! Coding tips, tricks, and treasures.

Possibilities weekly ezine

Get the weekly email website developers read:

 

Your email address

name@example.com
YES! Send Possibilities every week!

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.:

  1. 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

Was this article helpful to you?
(anonymous form)

Support This Website

Some of our support is from people like you who see the value of all that's offered for FREE at this website.

"Yes, let me contribute."

Amount (USD):

Tap to Choose
Contribution
Method

All information in WillMaster Library articles is presented AS-IS.

We only suggest and recommend what we believe is of value. As remuneration for the time and research involved to provide quality links, we generally use affiliate links when we can. Whenever we link to something not our own, you should assume they are affiliate links or that we benefit in some way.

How Can We Help You? balloons
How Can We Help You?
bullet Custom Programming
bullet Ready-Made Software
bullet Technical Support
bullet Possibilities Newsletter
bullet Website "How-To" Info
bullet Useful Information List

© 1998-2001 William and Mari Bontrager
© 2001-2011 Bontrager Connection, LLC
© 2011-2024 Will Bontrager Software LLC