Best way to handle 404 error with redirect to homepage
===

I've searched, read a lot, but still couldn't find a way, to achieve my goal. Now I even think it is impossible. Is it?

I want 404 errors to handled properly so I have `ErrorDocument 404 /404.php` in the .htaccess file, and I want to send out the right header to search engines `header("HTTP/1.1 404 Not Found")` to forget that page, **also** I want to redirect my visitor to `/index.php?code=404` so I can inform him about that what he was looking for is not available, but still keep him on the site.

Now it seems everything is fine, until I want to redirect the user: then the server sends out a 302 message, which overwrites my previous 404 header, so while I can send the user to the desired place, I still can't tell the searchbots that the address is wrong.

If I add a `include("index.php?code=404")` after the header line it just won't work, the server says that file does not exist.

What should I do?