T.David's Script ShopDetect where your surfers come from and redirect if it is not from the URL you selectTD's Detect/Redirect  - A very simple detect and redirect script (only 3 variables to define and 5 lines of code, so small there isn't even a need to download). This will make sure a surfer is coming from a specific URL and then redirect them to a sponsor or your signup page (or wherever you want) if they aren't. If they are blocking their HTTP_REFERER by using an anonymizer it will still prevent them from accessing your content page. Useful for content pages that you want to protect from outside linking. This is the CGI equivalent of the Javascript detect and redirect below, but is more reliable and secure since surfers can simply disable javascript in their browser and still get to your content page, but they can't disable CGI. If you can run CGI, use this or a variation thereof instead of the javascript version.

#!/usr/bin/perl
# TD Detect/Redirect 1.0 *
# Scripted by T.David *
# tddetect.cgi *
# Created 8/13/99  Last Modified 9/27/99 *
# This simple script is freeware and documented
#
# *****MODIFY THREE VARIABLES BELOW*****************************************
# Change detect to the page URL where the referrer must come from
$detect = "http://www.tdscripts.com/index.html";
# Change to the page URL where you want the CORRECT referral sent
$correct = "http://www.tdscripts.com/cgi-bin/tdkeno.cgi";
# Change to the page URL where you want the INcorrect referral sent
$incorrect = "http://www.tdscripts.com/keno.html";
#****************************************************************
# Instructions for using the script:
# 1. Upload this file via FTP in ASCII only to your cgi-bin
# 2. Telnet to your server and chmod 755 detect.cgi
# 3. Create a hyperlink from your correct HTML page to the script
# 4. You should be able to click from browser and be transferred to your  correct page
# 5. try to access the script from typing it in or a different page.
# 6. you should be directed to your incorrect page
#*****************************************************************************

# where is referrer coming from?
$referer = $ENV{'HTTP_REFERER'};
# if referrer not exactly from the url described in 'detect' then redirect to 'incorrect'
   if ($referer =~m#$detect#) {
   print "Location: $correct\n\n";
   } else {
   print "Location: $incorrect\n\n";
   }

TD Detect/Redirect (demo) Cut-n-paste script from above to txt file and name tddetect.cgi (No download is necessary). The demo will not take you to TD Keno login screen unless the address in your browser is exactly http://www.tdscripts.com/index.html. Now try typing in your browser and watch you be redirected to the Keno page. Cool, huh?

*Use of freeware versions requires a linkback to this page. Please use the following link syntax or you are welcome to take the 3D logo at the top of the page (just make sure you serve it from your server, please):

TDavid's Script Shop - Useful CGI-scripts for Webmasters with freeware versions

[ home ] [ write TDavid ] [ tdkeno ] [ links ]

Copyright 1999-2007 TDscripts All Rights Reserved