I've recently recreated DaveOsborne.com's web pages. I switched to PHP and MySQL from HTML. The site was already registered with the major search engines so I started getting alerts of 404 errors when people were being sent to the old .htm files.
As a solution to this I wrote a redirect program in PHP which handled the problem. Unfortunately, this doesn't work when the user has his or her Internet Explorer settings to display "Show friendly HTTP error messages". Therefore, I made individual .htm files alongside every .php file that redirected the browser to the .php file in those cases when it was sent to the .htm file from old links.
The following is a full copy of one of these redirect files. The only difference in these redirect files is the name of the .php file being redirected to. You can verify this by changing the URL of almost any of DaveOsborne.com's files so the file extension is .htm instead of .php, then clicking on your browser's Stop button before the redirect happens (pretty tricky but can be done) then using "View Source" on the .htm file.
<html>
<head>
<title>Transferring</title>
<script language="JavaScript">
if (document.cookie.indexOf("redirected=true") > -1) {
document.cookie = "redirected=false;path=/;";
history.back();
}
else {
document.cookie = "redirected=true;path=/;";
location.href="about.php";
}
</script>
</head>
<body>
<h1>If you see this page:</h1>
Your browser did not redirect properly.<br>
<a href="about.php">Click here</a>
</body>
</html>
If you know of a better way of redirecting without cookies that works on every browser and every browser setting then please email me!
Dan