astroboy has asked for the wisdom of the Perl Monks concerning the following question:

Hi all

we've just migrated from one CMS to another and the URLs are all different (yes I know that some people frown on this, but I have to make do with what's in front of me).

However, I have a database table that maps the old URL to the new ones, so I set the Apache error document to a perl script that will look up the mapping and redirect to the new url.

However, it's ocurred to me that I don't know how to get the requested address in my perl script. Dumping the %ENV hash only shows the error document script. Is there a way to get the original request? (mod_perl isn't an option, I'm afraid, otherwise I'd just intercept the request and do the translation before Apache would raise the not found error)

  • Comment on Website reorg - directing to the new URL

Replies are listed 'Best First'.
Re: Website reorg - directing to the new URL
by idsfa (Vicar) on Mar 25, 2006 at 03:27 UTC

    mod_rewrite with a prg MapType looks like what you want. The example on the page I linked to even uses perl ...

    #!/usr/bin/perl $| = 1; while (<STDIN>) { # ...put here any transformations or lookups... print $_; }

    The intelligent reader will judge for himself. Without examining the facts fully and fairly, there is no way of knowing whether vox populi is really vox dei, or merely vox asinorum. — Cyrus H. Gordon
      Thanks guys. Sometimes it's so obvious that I can't see the wood for the trees!
Re: Website reorg - directing to the new URL
by TedPride (Priest) on Mar 25, 2006 at 03:15 UTC