Welcome Guest, Not a member yet? Register   Sign In
The benefit of 404 pages
#1

[eluser]AzizLight[/eluser]
Hi everybody,

I've been coding my own minimalist blog engine using CodeIgniter (both to learn CI and develop my own website) and I realized how useful flashdata was to send feedback to the user. So my question is: What is the benefit of 404 pages when you can just redirect the user to wherever you want and display a one time feedback message? Did 404 pages become purely a "geeky" thing to add to the website, or do they still exist by pure convention? If not, then what is the real benefit of 404 pages over flashdata?
#2

[eluser]Myles Wakeham[/eluser]
[quote author="AzizLight" date="1253593708"]
I've been coding my own minimalist blog engine using CodeIgniter (both to learn CI and develop my own website) and I realized how useful flashdata was to send feedback to the user. So my question is: What is the benefit of 404 pages when you can just redirect the user to wherever you want and display a one time feedback message? Did 404 pages become purely a "geeky" thing to add to the website, or do they still exist by pure convention? If not, then what is the real benefit of 404 pages over flashdata?[/quote]

404 pages (the HTTP return code for 'Page not found') is a convention that pre-dates most PHP implementations and is part of the HTTP standard, I believe. Most webserver configurations allow you to set what is to be done when a 404 is received (ie. the page to send, etc.) so you have some control over it, but its something that's been around a long time before CI was ever thought of.

Myles
#3

[eluser]AzizLight[/eluser]
Yeah so as I said, today 404 pages are only used because it's "the convention" (or should I say "the tradition"? ), it doesn't have any "useful" advantages over any other alternative (ie flashdata)...
Please, if I'm wrong correct me..
#4

[eluser]BrianDHall[/eluser]
In a word...yes, I do believe you are correct. The only advantage I can think of is it specifically tells something like a search engine, or other such automated script, specifically that what they are looking for is not valid...and that I think is really it.

I suppose that's why CI's 404 is so lackluster - it just isn't important because there is so little reason to even use it, much less customize it to be special or interesting.
#5

[eluser]AzizLight[/eluser]
One last question based on the last answer:

Would it affect SEO, or would it be "bad" in ay way for a site not to have a 404 page even if it's not really useful in general?
#6

[eluser]BrianDHall[/eluser]
Only if you have quite a bit of links that go bad, like lots of articles that expire or posts that get deleted/purged, etc. The problem would be only if search engines started getting the idea that you have hundreds of unique links all over your site that are exactly the same page (ie, non-existant).

However, I tend to think this is a really minor issue, because how many of us support HTTP 401.2 - unauthorized to access this resource? I don't know about you, but I just redirect to a login page, return nothing, or return a simple error page telling the user they need to login. Most sites do, and they seem to be listed in Google just fine.

If this is an issue on your site, just use:

Code:
header("HTTP/1.0 404 Not Found");

...on pages that are really 404s, but you still maintain full control on how that page should look and behave and you can do that from within your normal controllers, etc. But it would officially 'support' 404 http codes.

The reality is that there is a difference in the 404 status code in HTTP and the actual - useless - 404 page. No reason I can think of not to eliminate traditional 404s in your programs and just 'manually' support 404 http code headers that way.

That would seem the perfect compromise between 'tradition' and modern convenience.
#7

[eluser]AzizLight[/eluser]
Thanks a lot for your answers Smile

That thread has been very informative, I saved it as a PDF file lol Smile
#8

[eluser]PromaneX[/eluser]
One thing that was not mentioned ( I know search engines were mentioned..) if you redirect all requests for non-existant pages to a particular page on your site and dont send the 404 header then you may get flagged for duplicate content (not good)
#9

[eluser]Phil Sturgeon[/eluser]
For larger sites a 404 can be very helpful, not just for tracking broken links with log files and keeping search engines up to date, but for getting users to the right place too. Here at work for example we offer up a few popular links, but some sites do it even better and offer suggestions based on the URI provided.

To have the best of both I would output a very simple 404 page which gives you a chance to output the 404 header. This will let search engines know the page is 404 and they can remove it from their index. Then just do a JavaScript or Meta-data redirect to get the user to the home-page or wherever you see fit. I avoid that sort of redirect on the whole as they cannot be relied upon for all users/browsers, but if the user already has a 404 page to look at it does not matter.
#10

[eluser]n0xie[/eluser]
We do it exactly like Phil Sturgeon suggested:

One of the adaptations we have is overruling the show_404() function in the Router Class, to point to a 404 controller, which inserts the 404 into a database, while sending out a 404 NOT FOUND header. It also tries to guess which page the visitor tried to visit and shows possible matches.

This is very handy because now you can look up in your database if you have missing or broken links, and also get a general idea of what a crawler/spider tries to index. If a persistent error is made (let's say the url has a '-' where it should have been a '_') we add a rewrite rule, so any spider will index the right page.




Theme © iAndrew 2016 - Forum software by © MyBB