Wednesday, November 19, 2008

404s fixed

We moved a folder:
/training/reacademy
became
/reacademy/
but search engines are still looking for the old URL.

How to fix this?

1. create a text file called /training/reacademy.php that contains:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<title>Tech Transfer Resources</title>
<meta http-equiv="refresh" content ="0; URL=http://www.techtransfer.berkeley.edu/reacademy/">
</head>
<body bgcolor="#ddeeff">

<h1>Please Update Your Bookmark</h1>

<p>
The page you accessed has been moved.
If you are not automatically redirected to the new location,
please click <a href="/reacademy/">here</a>.
Please update your bookmarks or favorites.
</p>
</body>
</html>
But, this gives log lines like:

"GET /training/reacademy HTTP/1.1" 200 673 "-"

If we want the crawlers to know the URL is no good, we need to send a 301 - Moved Permanently, so this is better:

<?php

header("Location: http://www.techtransfer.berkeley.edu/reacademy/",TRUE,301);

exit();
?>
Which gives:

"GET /training/reacademy HTTP/1.1" 301 5 "-"
"GET /reacademy/ HTTP/1.1" 200 23730 "-"

(According to w3.org:
Unless the request method was HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s).
So I also included the html as above, minus the "refresh" META tag.)

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home