Global Web Site Redirect
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> <h1>UMLGraph now lives under http://www.umlgraph.org</h1> 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.Read and post comments, or share through