7

As I shift many URL's on my site from non-friendly to friendly, I came across an old URL that was used for testing that google later ended up scanning but now I no longer use the URL. Its in the unfriendly form like this:

http://example.com/something.php?something=something&

In the past, that URL matched another on my site and in order to rectify it, I had to change the status code (and make the URL not return an actual webpage). At first I thought using the code 410 to indicate gone to google, but now I figured http status 400 is better because all my other "clean" URLs never contain an & in them and http status 400 stands for malformed request.

Is this an acceptable practice? or should I just convert it to http status 410? What would search engines think of this practice? (I'm just trying to follow standards here)

  • Wouldn't a 301 (moved permanently) to http://example.com/something.php?something=something useful? Or does that not exist either? – Hagen von Eitzen Aug 24 '15 at 18:42
  • Yes and no because some urls (particularly unfriendly ones) that once existed no longer exist. – Mike Aug 24 '15 at 23:22
27

Why 410 gone?

Since the page once existed the correct header status return would be 410 gone, this will inform Google and other search engines to drop the page from its index. You should avoid using status 400 bad request since this implies the server did not understand the request due to malformed syntax. Using undesirable status codes will populate your error logs and can make fault finding harder on actual issues.

What about 404?

Using either a 404 or 410 statuses is considered ok, however… if you know the page is never coming back then its best to use a 410 gone. Google has said that they treat the outcome of 404 and 410 the same but the 410 is dropped quicker due to the fact that 404’s can occur when it’s not intended.

  • 5
    +1, agreed. A "404 Not Found" response would also be a valid choice here. – Ilmari Karonen Aug 23 '15 at 23:25
  • @IlmariKaronen "Gone" is different from "Not Found." – Anubian Noob Aug 25 '15 at 4:26
  • 2
    @AnubianNoob: "Gone" is, more properly, a subset of "Not Found"; if it's gone, it's not there to be found any more. Indeed, the 410 Gone status code was added in HTTP/1.1 basically as a more specific and emphatic version of 404, to let servers explicitly indicate that a formerly valid resource has been deliberately and permanently removed (as opposed to, say, just being accidentally or temporarily inaccessible). – Ilmari Karonen Aug 25 '15 at 8:23
  • @IlmariKaronen true, but administrators may favour 410's because they drop faster than 404's. – Simon Hayter Aug 25 '15 at 18:07
15

Officially, yes. Any 4xx status may be interpreted as 400; the same goes for the other status groups. (E.g. a 503 service unavailable error may be interpreted as a 500 internal server error.)

The RFC is written this way to allow for implementations that may not support every status, and also to allow additional status codes to be defined without breaking backwards compatibility.

So yes, you may use 400 instead of 410. However, you should use the most accurate status available to you to describe the current state; if the resource is gone, isn't ever coming back, and can't (to your knowledge) be found anywhere else, 410 is the appropriate status. I'd probably use 404 before 400.

The reference for this behaviour is RFC 7231 (HTTP 1.1: Semantics and Content), Section 6. (Note that RFC 7231 and others supersede RFC 2616.)

2

Malformed request doesn't mean "a URL you don't have a resource for". It means malformed request. HTTP 400 is definitely wrong here.

HTTP 410 works well as it indicates that a previously accessible resource no longer is.

Your alternative, as others have mentioned, would be a 404.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.