Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.