Hi,
I'm trying to do something that I guess can't be done, but I need somebody to confirm it or otherwise give me a helping hand with a solution.
I'm implementing some mod_rewrite rules on my homepage (a weblog). In short I want the headline to be part of the URL (like you see ... other places), for example 'mypage.com/blog/Some_headline/'. This works just fine, and I can lookup the (modified) headline in the database and show the related article.
However, what happens if someone requests 'mypage.com/blog/This_Article_Does_not_exist/'? Surely, I want to redirect the user to my fabulous 404-page. Here, I have a message saying something like "Sorry, the page $_SERVER['REQUEST_URI'] does not exist. Blah blah blah." and the requested URL stays in the address field of the browser.
This also works fine - but only if someone requests a file, that is not recognized by my RewriteRules in .htaccess. If I look up a headline in the database and can't find any, I use a 'header("HTTP/1.1 404 Not Found")' to redirect the user to a proper 404, but all I get is a blank page.
Isn't it possible to redirect the user properly to my custom 404, show the message "Sorry, the page 'This_Article_Does_not_exist' does not exist" and keep the requested URL in the address field? I have tried using a 'header("Location: /include/404.php")' and in this case the 404-page states that it can't find '/include/404.php' and that's just silly...
I hope someone can help.