View Single Post
Old 05-21-2001, 08:19 PM  
Theo
HAL 9000
 
Industry Role:
Join Date: May 2001
Posts: 34,515
look what i do and it's quite simple
.htaccesss
-----start--------------------
ErrorDocument 401 /redir.php?401
ErrorDocument 403 /redir.php?403
ErrorDocument 404 /redir.php?404
ErrorDocument 500 /redir.php?500
----------end---------------

now the redir.php file is the following:


<?php

$DATA_FILE = "redirect.php";
$home = "http://www.yourdomain.com";

// do not edit this area
// ----------------------------------------------------------
if (strlen($QUERY_STRING) > 1) {
if (file_exists($DATA_FILE)) {
$fp = fopen("$DATA_FILE", "a");
flock($fp, 1);
$count = $QUERY_STRING;
$ip = $REMOTE_ADDR;
$from = " from ";
$today = gmdate("F j, Y, g:i:s a");
$space = " -- ";
$time = mktime();
$newline = "
";
fseek($fp,0);
fputs($fp, $today);
fputs($fp, $space);
fputs($fp, $count);
fputs($fp, $space);
fputs($fp, $from);
fputs($fp, $ip);
fputs($fp, $newline);
flock($fp, 3);
fclose($fp);
} else {
echo "Can't find file, check '\$file'
";
}

// add custom queries, ie: http://blah.com/redir.php?yourdomain

if ($QUERY_STRING == "401") { $url = "http://www.sponsor.com"; }

else if ($QUERY_STRING == "402") { $url = "http://www.sponsor.com"; }

else if ($QUERY_STRING == "403") { $url = "http://www.sponsor.com"; }

else if ($QUERY_STRING == "404") { $url = "http://www.sponsor.com"; }

else if ($QUERY_STRING == "500") { $url = "http://www.sponsor.com"; }
// Do not edit below
else { $url = $QUERY_STRING; }
}
else {
$url = $home;
}
header("Location: $url");
echo "redirecting...";
?>

you redirect the user depending the situation and you keep the data on redirect.php - be sure that the redirect.php has the right file permissions.



------------------
Great Money Makers! Top Sponsors
Theo is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote