网站针对找不到页面 (404) 页面返回 HTTP 代码 200 是否正常?
我正在对一些网站(我不会提及)进行一些测试,当它们是未找到页面时,它们会返回 200 代码。 这是否违反任何网络开发标准?
这是我用来查看 URL 返回代码的代码:
System.out.println(new String("getRespCode=" + urlConnection.getResponseCode() + ", HttpURLConnection=" + HttpURLConnection.HTTP_OK + "\n"));
有什么想法吗?
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?
This is the code that I am using to see the return code of a URL:
System.out.println(new String("getRespCode=" + urlConnection.getResponseCode() + ", HttpURLConnection=" + HttpURLConnection.HTTP_OK + "\n"));
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这称为
Soft 404
或False 404
。 维基百科有详细讨论。 任何网络标准都不允许这样做(而且我不知道有任何支持的论点),但无效的 HTML 也是如此。This is called a
Soft 404
orFalse 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.听起来他们这边有一个错误。 404 错误也有可能被重定向到另一个页面以显示更好的响应,并且该页面正在发送 200。
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.
这是常见的,但不正确。 例如,搜索引擎会相信他们正在访问有效的页面
It is common, though incorrect. Search engines will believe they're visiting a valid page, for example
是的,这绝对不符合标准。 这就像当你的汽油用完时你的油灯会亮起。
不幸的是,这种情况很常见; 然而,这并不意味着这是可以接受的。
phihag 留下了一个很好的链接,值得一读。
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.
请注意,对于真正的 404,您的代码(据我记得)不会执行,但会产生 FileNotFoundException。
Note that for true 404's your code (as far as I remember) would not execute, but yield a FileNotFoundException.