在 DNS 重定向错误的情况下,发送的正确 HTTP 响应是什么?
我有一台托管多个网站的服务器。服务器是用Java+Jersey编写的。 如果有人将他的 DNS 指向我的服务,但该 DNS 与我的任何托管网站都不匹配,我应该怎么回答?请注意,我需要以编程方式执行此操作,并且不能依赖于 Web 容器 (Tomcat) 的某些自定义。
问题是,如果我显示“未找到网站”页面,我将使搜索引擎以虚假名称引用我的主域网站,从而由于其他人的错误而降低其页面排名。
我尝试更改我的 /etc/hosts 文件以重现该行为,但无法猜测其他网站在这种情况下也在做什么。
有什么想法吗?简单的404似乎太轻了?错误的请求似乎不合适......
I've got a server hosting multiple websites. Server is written in Java+Jersey.
If someone makes his DNS point to my service, but this DNS doesn't match any of my hosted websites, what should I answer? Note that I need to do this programmatically and can't rely on some customization of my Web container ( Tomcat ) .
The problem is, if I display a « website not found » page, I shall have search engines reference my primary domain website under a false name, therefore downgrading its page rank because of someone else's mistake.
I tried to change my /etc/hosts file to reproduce the behaviour but can't guess what other websites are doing in this case too.
Any idea ? A simple 404 seems too light ? Bad Request seems inappropriate ...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
肯定是 4xx,因为错误来自请求(
Host
标头包含无效值)。我会说 404,未找到可能是这里最好的答案。这将阻止搜索引擎索引。
另一个解决方案可能是(永久)重定向到您网站的主域?我已经见过几次这种行为了。
Definitely a 4xx, since the error comes from the request (the
Host
header contains an invalid value).I would say 404, Not found is probably the best answer here. This will prevent indexing from search engines.
Another solution could be to redirect (permanently) to the main domain of your website? I have seen this behaviour a few times.
如果您确实不想要 404,那么 403 看起来可能就是您想要的。来自 RFC 2616:
If you really don't want 404, 403 looks like it might be what you want. From RFC 2616:
没有真正回答你的问题,但评论太复杂了。以下是一些想法:
如果您针对其他人的网址显示“网站已移动”消息,那么这不会以任何方式影响您的其他域。蜘蛛程序不应将内容归因于您的域,也不应更改您的链接排名。
我认为您永远没有任何方法可以“降低”您的网页排名。您要么有指向您的内容的链接,要么没有。 Pagerank 仅衡量入站链接 - 不可能有“坏”链接链接在网页排名方面。
如果您想从他们糟糕的 DNS 中受益,那么我只需使用正确的主机名将它们重定向到您的主页即可。如果我得到的主机名与我的域不完全匹配,这就是我在网络服务器上所做的事情。
希望这会有所帮助。
Not really answering your question but the comment was too involved. Here are some thoughts:
If you show a "website has moved" message for someone else's URL then that will not affect your other domains in any manner. The spiders should not attribute the content to your domain nor change your link ranking.
I don't think there is any way for you to "downgrade" your page rank -- ever. Either you have a link to your content or not. Pagerank is a measurement of the inbound links only -- there is no way to have a "bad" link in terms of Pagerank.
If you want to benefit from their bad DNS then I would just redirect them to your homepage with a proper host name. That's what I do on my webserver if I get a hostname that doesn't match my domain exactly.
Hope this helps somewhat.