0

We will migrate an entire intranet from one CMS to another. All URLs will change in a non-predictable pattern, but I can capture a file with original,new URLs I can feed into anything. I have hundred thousands of URLs, not just a few hundred.

What I would like to do: every URL that is not found (404) should be checked against the database and if a new URL found a 301/308 issued instead. Some trickery to suggest similar pages in the 404 message if the lookup was unsuccessful would be an added bonus.

Is that the right approach or should I check redirection first all the time?

How would I do that in Apache2? Is that a custom 404 module?

stwissel
  • 640
  • 2
  • 7
  • 21

1 Answers1

0

I figured it out, partly. While the 404 still eludes me, I can use mod_rewrite and the RewriteMap directive to proactively rewrite URLs instead of relying on a 404 status first. This could work:

RewriteEngine on
RewriteMap lowercase int:tolower
RewriteMap blog-map dbm:/home/stw/www/blogmap.map
RewriteRule ^/blog/d6plinks/(.*) /blog/${blog-map:${lowercase:$1}} [NC,R=301,L]

Detailed description here. now with a ErrorDocument statement the original goal might be achievable.

stwissel
  • 640
  • 2
  • 7
  • 21