I am transferring a large static website of 500+ pages to a Joomla installation but what I am wanting to do, rather than code a 500+ line .htaccess file, is to use PHP's built in 301 header redirect to dynamically redirect requests that come in to the new URL.
So for example, after I move the site, the following URL would 404 without a redirect-
http://www.foo.com/old_page.html
I would want it to redirect to
http://www.foo.com/old-page.php
So I would like to create a MySQL database of old URLs and their corresponding new URL and then, if the server is going to return a 404, for it first to check the DB for the existing old URL, and if matched, to issue a 301 redirect to the new URL. Right, am I making sense here?
How would I do that? I can "talk" the logic but not really sure where to begin or how to accomplish it because, while I understand PHP, I don't really understand how this would work with Apache (or even if it would for example...)?
And if you know of any scripts out there that are already doing this, all the better.