Near the top of my PHP script I call the shrink_url() function, which I have preloaded with a require_once("funcs.php") statement. funcs.php includes this function:
{
$currenturl =curPageURL();
$servername = $_SERVER["SERVER_NAME"];
$scriptname = $_SERVER["SCRIPT_NAME"];
foreach ($_GET as $key => $value)
{
if ($value <> "") {$getparams .= "&" . $key . "=" . urlencode($value);}
}
$getparams = substr($getparams,1);
if ($getparams <> "") $getparams = "?" . $getparams;
$redirect = "http://" . $servername . $scriptname . $getparams;
if ($currenturl <> $redirect)
{
ob_end_clean(); //stops loading the current page.
header("Location: $redirect"); //redirects to the shrunken URL.
}
}
No comments:
Post a Comment
Constructive, concise comments are welcome.