I was doing some testing with some sites (that I will not mention), and they are returning 200 code when they are page not found pages. Is this against any web development standard?
我正在对一些网站进行一些测试(我不会提及),并且当它们是页面未找到页面时它们返回200个代码。这违反了任何Web开发标准吗?
This is the code that I am using to see the return code of a URL:
这是我用来查看URL返回码的代码:
System.out.println(new String("getRespCode=" + urlConnection.getResponseCode() + ", HttpURLConnection=" + HttpURLConnection.HTTP_OK + "\n"));
Any ideas?
5 个解决方案
#1
This is called a Soft 404
or False 404
. Wikipedia has a detailled discussion. It is not allowed by any web standard (and I don't know of any argument in favor), but so is invalid HTML.
这称为Soft 404或False 404.*有详细讨论。任何Web标准都不允许这样做(我不知道有任何论据支持),但HTML也是无效的。
#2
Sounds like an error on their side. It may be possible too, that the 404 error was redirected to another page to display a better response, and that page is sending the 200.
听起来像他们身边的错误。也有可能将404错误重定向到另一个页面以显示更好的响应,并且该页面正在发送200。
#3
It is common, though incorrect. Search engines will believe they're visiting a valid page, for example
这很常见,但不正确。例如,搜索引擎会相信他们正在访问有效页面
#4
Yes, it is absolutely against standards. Thats like your oil light coming on when you're running out of gas.
是的,它完全违反标准。就像你的油灯耗尽时油灯一样。
Unfortunately it is common; however, that does not imply that it is acceptable.
不幸的是,它很常见;但是,这并不意味着它是可以接受的。
phihag left a good link, worth reading.
phihag留下了一个很好的联系,值得一读。
#5
Note that for true 404's your code (as far as I remember) would not execute, but yield a FileNotFoundException.
请注意,对于真正的404,您的代码(据我记得)不会执行,但会产生FileNotFoundException。
#1
This is called a Soft 404
or False 404
. Wikipedia has a detailled discussion. It is not allowed by any web standard (and I don't know of any argument in favor), but so is invalid HTML.
这称为Soft 404或False 404.*有详细讨论。任何Web标准都不允许这样做(我不知道有任何论据支持),但HTML也是无效的。
#2
Sounds like an error on their side. It may be possible too, that the 404 error was redirected to another page to display a better response, and that page is sending the 200.
听起来像他们身边的错误。也有可能将404错误重定向到另一个页面以显示更好的响应,并且该页面正在发送200。
#3
It is common, though incorrect. Search engines will believe they're visiting a valid page, for example
这很常见,但不正确。例如,搜索引擎会相信他们正在访问有效页面
#4
Yes, it is absolutely against standards. Thats like your oil light coming on when you're running out of gas.
是的,它完全违反标准。就像你的油灯耗尽时油灯一样。
Unfortunately it is common; however, that does not imply that it is acceptable.
不幸的是,它很常见;但是,这并不意味着它是可以接受的。
phihag left a good link, worth reading.
phihag留下了一个很好的联系,值得一读。
#5
Note that for true 404's your code (as far as I remember) would not execute, but yield a FileNotFoundException.
请注意,对于真正的404,您的代码(据我记得)不会执行,但会产生FileNotFoundException。