网站针对找不到页面 (404) 页面返回 HTTP 代码 200 是否正常?

发布于 2024-07-16 07:54:26 字数 285 浏览 3 评论 0原文

我正在对一些网站(我不会提及)进行一些测试,当它们是未找到页面时,它们会返回 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

桃扇骨 2024-07-23 07:54:26

这称为 Soft 404False 404。 维基百科有详细讨论。 任何网络标准都不允许这样做(而且我不知道有任何支持的论点),但无效的 HTML 也是如此。

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.

安静 2024-07-23 07:54:26

听起来他们这边有一个错误。 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.

佞臣 2024-07-23 07:54:26

这是常见的,但不正确。 例如,搜索引擎会相信他们正在访问有效的页面

It is common, though incorrect. Search engines will believe they're visiting a valid page, for example

友谊不毕业 2024-07-23 07:54:26

是的,这绝对不符合标准。 这就像当你的汽油用完时你的油灯会亮起。

不幸的是,这种情况很常见; 然而,这并不意味着这是可以接受的。

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.

汹涌人海 2024-07-23 07:54:26

请注意,对于真正的 404,您的代码(据我记得)不会执行,但会产生 FileNotFoundException。

Note that for true 404's your code (as far as I remember) would not execute, but yield a FileNotFoundException.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文