Now, this isn't rocket science, but I came up with a way to have my cake and eat it too. I set up an ErrorDocument handler called 404.php that was a script that can redirect people based on their incoming URLs, Referrers, etc:
<?php
# Useful _SERVER variables:
# REDIRECT_URL - original URL of request
# REQUEST_URI - original URI of request?
$map = array(
"/old/url/path" => "http://www.domain.com/new/path/"
);
if ( $map[$_SERVER['REQUEST_URI']] ) # if the request is in the map
{
header("HTTP/1.0 302 Moved");
header("Location: ".$map[$_SERVER['REQUEST_URI']]);
exit();
}
if ( substr($_SERVER['REQUEST_URI'], 0, 9) == "/download" )
{
header("HTTP/1.0 302 Moved");
header("Location: http://www.domain.com/new/download/path/");
exit();
}
?>
I checked our access logs for 404 errors a few times a week and added into the map the most common hits.
Well, I thought it was clever...
No comments:
Post a Comment