Global Web Site Redirect

 

I recentry moved UMLGraph to its own dedicated web site. After the move a friend pointed out that all the links in Martin Fowler's web page on UmlSketchingTools would now stop working.

A few years ago I wrote an article about the problem of the decaying URL links, so I'd hate to be part of this problem. As a solution, I wrote a small shell script that replaced all the web pages in the original site with a redirect to the corresponding page on the new site. You can see it below. Note the use of a here document with parameter substitution to have cat generate the redirect page with the appropriate URLs.

#!/bin/sh
# Find all HTML pages
find . -name '*.htm*' |
# Remove leading ./
sed 's/.\///' |
# Read each the filename
while read f
do
	# Replace contents with the redirect
        cat <<EOF >$f
<!doctype html public "-//IETF//DTD HTML//EN">
<html>
<head>
<title>UMLGraph now lives under http://www.umlgraph.org</title>
<META HTTP-EQUIV="Refresh" CONTENT="2; URL=http://www.umlgraph.org/$f">
</head>
<body>
<h2>UMLGraph now lives under http://www.umlgraph.org</h2>
In line with the increasing involvement of the UMLGraph
community in the development and support of UMLGraph,
UMLGraph now lives under its own domain.
If you have arrived to this page through a link,
please update it or notify its administrator.

The page's new location is <a href="http://www.umlgraph.org/$f">http://www.umlgraph.org/$f</a>.
Follow this link if you are not redirected automatically there in
two seconds.
</body>
</html>
EOF
done

The script worked perfectly. Maybe there's also an Apache module that can do something similar. (Keep in mind that in order to avoid serving duplicate content I wanted a redirect with a notification, not a simple alias.) However, I prefer to solve the problem once and forall through static web pages, than to add another module to the maintenance and dependencies of the site's web server.

Comments   Toot! Share


Last modified: Saturday, December 8, 2007 7:55 am

Creative Commons Licence BY NC

Unless otherwise expressly stated, all original material on this page created by Diomidis Spinellis is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.