let their service fall to intolerably low levels; if you are unlucky enough to have signed
up with such an ISP, there is not much recourse but to change providers, and that often
implies a change of web addresses.§
Imagine, though, that you are an O’Reilly author and have published your website’s
address in multiple books sold widely all over the world. What do you do when your
ISP’s service level requires a site change? Notifying each of the hundreds of thousands
of readers out there isn’t exactly a practical solution.
Probably the best you can do is to leave forwarding instructions at the old site for some
reasonably long period of time—the virtual equivalent of a “We’ve Moved” sign in a
storefront window. On the Web, such a sign can also send visitors to the new site
automatically: simply leave a page at the old site containing a hyperlink to the page’s
address at the new site, along with timed auto-relocation specifications. With such
forward-link files in place, visitors to the old addresses will be only one click or a few
seconds away from reaching the new ones.
That sounds simple enough. But because visitors might try to directly access the address
of any file at your old site, you generally need to leave one forward-link file for every
old file—HTML pages, images, and so on. Unless your prior server supports auto-
redirection (and mine did not), this represents a dilemma. If you happen to enjoy doing
lots of mindless typing, you could create each forward-link file by hand. But given that
my home site contained over 100 HTML files at the time I wrote this paragraph, the
prospect of running one editor session per file was more than enough motivation for
an automated solution.
Page Template File
Here’s what I came up with. First of all, I create a general page template text file, shown
in Example 6-7, to describe how all the forward-link files should look, with parts to be
filled in later.
Example 6-7. PP4E\System\Filetools\template.html
This page has moved
This page now lives at this address:
§It happens. In fact, most people who spend any substantial amount of time in cyberspace could probably tell
a horror story or two. Mine goes like this: a number of years ago, I had an account with an ISP that went
completely offline for a few weeks in response to a security breach by an ex-employee. Worse, not only was
personal email disabled, but queued up messages were permanently lost. If your livelihood depends on email
and the Web as much as mine does, you’ll appreciate the havoc such an outage can wreak.
Generating Redirection Web Pages| 293