Redirect to a different page if the PURL does not exist.

Want to redirect to a different website when a PURL does not exist?  Follow the steps below...

1. Locate the index.php File

Login to your server via FTP and locate the index.php file located in the purlpage_yourcampaignname folder.  (yourcampaignname will obviously be your campaign name).

If you are using instantPURL to host your landing page on our server, you'll need to first request FTP access

Need help with this step? Email us support@purlem.com

2. Add the Redirect Code

If you open the index.php file, you will notice some PHP "PURL CODE" at the top of the file that looks similar to this:

$data = @file_get_contents('http://purlapi.com/lp/index.php?ID='.$_GET["ID"].'&name='.$_GET["name"].'&page='.$_GET["page"].'&qr='.$_GET["qr"].'&mobile='.$mobile.'&test='.$_GET["test"].''); if(empty($data)) { echo 'PURL Not Found'; exit; } $visitor = json_decode($data); /*Begin Campaign Redirect*/if($visitor->{'purlpage'} && (stristr($_SERVER['REQUEST_URI'], $visitor->{'purlpage'})) === FALSE) { header('Location: '.$visitor->{'url'}.'/'.$visitor->{'purlpage'}.'?ID='.$_GET["ID"].'&name='.$_GET["name"].'&page='.$_GET["page"].'&test='.$_GET["test"]); } /*End Campaign Redirect*/ @session_start(); if($_GET['username']) $_SESSION['visitor']=$_GET['username']; if($visitor->{'login'} && ($_SESSION['visitor'] != $visitor->{'firstName'}.''.$visitor->{'lastName'})) { echo $visitor->{'login'}; exit; }
	

Near the second line (in bold above) you'll notice echo 'PURL Not Found'; 

All you need to do is replace the words echo 'PURL Not Found'; with the the code below:

header( 'Location: http://www.yoursite.com' ) ;
	

You would obviously replace yoursite.com with your domain name.

You'll end up with something like this:

$data = @file_get_contents('http://purlapi.com/lp/index.php?ID='.$_GET["ID"].'&name='.$_GET["name"].'&page='.$_GET["page"].'&qr='.$_GET["qr"].'&mobile='.$mobile.'&test='.$_GET["test"].''); if(empty($data)) { header( 'Location: http://www.yoursite.com' ); exit; } $visitor = json_decode($data); /*Begin Campaign Redirect*/if($visitor->{'purlpage'} && (stristr($_SERVER['REQUEST_URI'], $visitor->{'purlpage'})) === FALSE) { header('Location: '.$visitor->{'url'}.'/'.$visitor->{'purlpage'}.'?ID='.$_GET["ID"].'&name='.$_GET["name"].'&page='.$_GET["page"].'&test='.$_GET["test"]); } /*End Campaign Redirect*/ @session_start(); if($_GET['username']) $_SESSION['visitor']=$_GET['username']; if($visitor->{'login'} && ($_SESSION['visitor'] != $visitor->{'firstName'}.''.$visitor->{'lastName'})) { echo $visitor->{'login'}; exit; }
	

3. Save & Upload

Once you made the change, save and upload the file back up to the server.   The new error message will now be displayed when a person types in the wrong url. 

If you need help with any of this, you can email us at support@purlem.com