I do it like this on my site, after I changed the site structure.
These are the contents of the 404 error file
Code
  
<?php

// get the link from the url
// in this case one would have to get the post number from it

$pathinfo = rtrim(trim($_SERVER['REQUEST_URI']),"/");

//the (excerpt from the) array that holds the old and new links
//one can use the database to pull the link pairs

$location['/contact.htm']= '/English/Contact';
$location['/pf/tyvek.htm']= '/English/Tyvek';
$location['/flowhood']= '/English/Flowhood';


if (array_key_exists($pathinfo, $location)){
	$header = "HTTP/1.1 301 Moved Permanently";
	header($header);
	header("Location: $location[$pathinfo]");
	exit;

}else{

print <<< END
	<html>	
	<head>	
	<title>Page Not Found !</title>
	</head>	
	<body>
		Some error message....
	</body>
</html>

END;
}