4 ms·
I would disagree. If I request twitter.com/userr but there is not account named "userr", should twitter decide I misspelled that and redirect me to "user" if t
by varikin 15y ago
I would disagree.
If I request twitter.com/userr but there is not account named "userr", should twitter decide I misspelled that and redirect me to "user" if that exists? I say no.
First of all, a 404 response needs to be sent regardless so that a script can check for 404 and handle that as deemed appropriate. If I got a 301 or 302 to what the server thought was what I was looking for, the script won't know that the server is now guessing at what I wanted. I assume this is important for bots like the google crawler.
Second, content with that 404 is very useful. It adds context to a user that cares. A well designed 404 will tell the user that the page/item/person/etc couldn't be found. Then it will offer an action such as suggestions of what it could be. Getting back to my "userr" example, there could be links to "user", "users", etc. There could be a prominent search feature or a way to report this to the company. Maybe a way to contact support, like a live chat widget. Further more, a 404 in your logs are very useful to look for what is commonly not found. Do people regularly try going to example.com/login even though your login page is at example.com/user_login? Apache access logs will show this very nicely and you can then decide to manually add a redirect.
- Cushman 15y agoTo your first point, I don't see the issue. Your crawler hits a URL and gets 301. It's either redirected to a URL already in its canonical database, and therefore knows that the redirected URL is garbage, or it gets something new-- congratulations! 404 is for a resource which can't be found; if the resource can be found, 404 is wrong for scripts as much as for users. Your second point is valid, but a little past the point, I think. My only actions after seeing a 404 are to check my spelling, hit back, close the tab, or start from the site root. Maybe it would be good for my browser to redirect to / or something by default, assuming there isn't a page loaded; I'm open to ideas. I'm just saying, it's never been helpful to me to download a 1.2mb transparent png that says "Sorry your browser doesn't know what 404 means." (Or another example ripped from real life: I literally just now hit a link to a video on a third-tier media site and was rewarded with a completely different video, with little text at the top that says "Error: Not found". This is what people really use custom 404s for.)