Apache Rewriting
By Lincoln D. Stein
Recently I had to solve a classic problem in Web server administration: moving a large multipage document from an old server to a new server. In this case, the old server was an NCSA httpd site, and the new server was running Apache. The good news was that because the document had been designed with portability in mind, most of the hyperlinks and inline images used relative URLs. This meant that the links and images kept working even when the tree was moved from one directory structure to another. The bad news was that the document tree made extensive use of black-and-white X bitmap MIME-type icons (.xbm), maintained in the NCSA server /icons directory. For example, it used the tag <IMG SRC="/icons/movie.xbm"> whenever it linked to an animation file. Apache is backward compatible with NCSA httpd, even to the point of having its own /icons directory. However, nobody uses the old .xbm icons these days, and Apache replaced its MIME-type icons with colorful GIF icons a long time ago. As a result, everywhere the document referred to an .xbm file, the browser displayed a broken picture icon instead.
At this point I had several options open. One option was to write a Perl script to go through the document tree and change all instances of "something.xbm" to "something.gif". With the UNIX find program or the Perl find2perl script, this solution would be trivial. However, this approach involved changing the documents' HTML source code, and since I wasn't the author I felt uncomfortable doing this.<>