With Apache and mod_rewrite you can designate a particular page or script to be served whenever some other page isn't found. This decision gets made before the 404 error handler ever gets invoked. Don't return a 404 then return the proper content. 404 is an error. Leave it an error.