I'm currently coding a site and I want to know the best alternative.
Should I add header("HTTP/1.0 404 Not Found")
without redirecting or should I redirect and add a 404 header?
404s should not always be redirected. 404s should not be redirected globally to the home page. 404s should only be redirected to a category or parent page if that's the most relevant user experience available. It's okay to serve a 404 when the page doesn't exist anymore (crazy, I know).
The select Manage on the menu on the left side of the screen, and Redirects on the menu that opens up from there. Click the Add Rule button. Enter the page you want to redirect in the box on the left. Select the type of redirect in the dropdown menu.
Redirecting means "What you asked for is actually over here".
If it isn't found, then it isn't found. Don't redirect.
Output a 404 status code, and then an HTML document that explains that whatever was requested wasn't found. You can then suggest an onwards journey by, for example, providing links to the main sections of the site or performing a search based on keywords extracted from the URL.
(The practical consequences of redirecting are that the URL vanishes from the address bar which makes it hard to look at an think "Oh, I mistyped that one letter, I'll just change it" or to copy/paste it into a bug report, etc).
header("Status: 404 Not Found"); //FastCGI
include("404.php");
exit;
URI remains the user asked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With