What makes it wrong? HTTP/HTTPS URLs/URIs don't mean files on the disk. You can return 200 as a default if you like.
What makes it wrong? HTTP/HTTPS URLs/URIs don't mean files on the disk. You can return 200 as a default if you like.
The correct response code would be a 3XX or 4XX response code, depending on the client behavior that you want.
In this specific case, a 303 response that redirects to the homepage would be most correct.
Alternatively, you could return a 404 response alongside the default content.
The point is, "resource" is an abstraction that servers may implement as they wish. The only requirements, per HTTP, is that (1) it's something that can be identified with a URI (satisfied in this case), and (2) it has information associated with it that can be retrieved and/or managed via the HTTP protocol (satisfied in this case).
We might imagine that the set of resources should be finite, or strictly mapped to extant data records in our system – but these are not requirements.
Many responses here seem to be based on the misunderstanding that this is about "not following a standard is sometimes okay-ish", when it's actually about the fact that the standard does not rigorously define what a "resource" is and what it means for the resource to "exist", other than a circular definition based on status codes.
You talk about violating conventions and standards. The conventions are defined by the HTTP spec. The standard is the HTTP spec. Neither are, so far as I can tell, being violated here.
Clearly they aren't requirements as I can think of many valid use cases that violate them.
To me, creating an infinite number of identical aliases for a single resource is clearly wrong. The only reason to do it is either incompetence or laziness.
Isn't that just begging the question? What defines whether a resource exists? Is it the client's knowledge about the webserver backend configuration, or the server's? If a server returns a 200 response, the resource exists, by definition. It may or may not have data, but again, that's not up to the client to decide. If the server says the resource exists and has no data, then that's the authoritative answer.
What if you want to confuse the client?
If the client behavior you want is to display your styled error page, that has historically meant returning a 200 status code, because some user-agents prefer their own error displays.
It’s like saying “what makes it wrong to signal left but turn right?”
It makes the component you’re operating behave less predictably, resulting in a less stable system overall. Follow the spec.
> It’s like saying “what makes it wrong to signal left but turn right?”
No, it's not like that. Signalling left but turning right would be like returning a 200 for a resource that does not exist.