|I use PHP header("Location: ... function to redirect, rather than .htaccess URL rewriting. This is because some of my URL text searches and changes are rather complex and are very difficult to do in .htaccess, and having good string-handling functions makes it much, much, easier. Anyway, .htaccess kicks any file or directory not found over to my script, and I redirect. My question is, what's the best way to handle genuinely "not found" references? I still have a 404.shtml file but .htaccess is grabbing such files and sending on to my redirection script. |
In the redirection script, when I encounter a request that I cannot redirect to a real file, I tried just setting the HTTP status to 404 (with and without header("Location: /404.shtml");), but that gives me a 500 (internal server) error. Is there some way to invoke the real 404.shtml, along with all the reference information (server side includes) needed to display? Should I re-implement 404.shtml in PHP and just directly invoke it from my redirection script? I'm assuming that $_SESSION or $_SERVER contains the information I want to display. Is there a better way to handle this?