i wouldn't suggest using .htaccess, kinda slow, i would use Apache's ErrorDocument directive, which you could be talking about, but using the wrong lingo
ErrorDocument 404 http://localhost/catch404page.php
then use that page to grab the requested page, like Pig said, and you are on your way
just to clarify, the .htaccess does the same as ErrorDocument, but it is slower (in computer time) than .htaccess, and you need to understand that if you have a .htaccess file, the server looks thru that for every request to the directory with that file, and every directory beneath that tree as well, but the ErrorDocument will only run when an actual error occurs