Rails/Passenger/Apache:简单的一次性 URL 重定向以在服务器移动后捕获过时的 DNS

发布于 2024-07-29 13:54:33 字数 409 浏览 5 评论 0原文

我的 Rails 应用程序之一(使用乘客和 apache)正在更改服务器主机。 我已经让应用程序在两台服务器(测试中的新服务器)上运行,并且 DNS TTL 为 5 分钟。 一位同事告诉我(我自己也经历过类似的事情),有时 DNS 解析器会稍微忽略 TTL,并且在我将 DNS 更新到新服务器后,可能会将旧 IP 缓存一段时间。

因此,在我打开 DNS 开关后,我想做的就是破解旧服务器,为所有访问者强制重定向到新服务器的 IP 地址。 显然,我可以在 Apache 或应用程序本身中执行许多重定向(301、302)。 我想避免使用 app 方法,因为我不想仅针对这一实例进行代码签入和部署,因此我认为基本的 http url 重定向会起作用。 但是,如果谷歌访问旧网站等,则会产生 SEO 影响。

如何最好地实现重定向,同时保持搜索引擎的良好性?

One of my rails apps (using passenger and apache) is changing server hosts. I've got the app running on both servers (the new one in testing) and the DNS TTL to 5 minutes. I've been told (and experienced something like this myself) by a colleague that sometimes DNS resolvers slightly ignore the TTL and may have the old IP cached for some time after I update DNS to the new server.

So, after I've thrown the switch on DNS, what I'd like to do is hack the old server to issue a forced redirect to the IP address of the new server for all visitors. Obviously I can do a number of redirects (301, 302) in either Apache or the app itself. I'd like to avoid the app method since I don't want to do a checkin and deploy of code just for this one instance so I was thinking a basic http url redirect would work. Buuttt, there are SEO implications should google visit the old site etc. etc.

How best to achieve the re-direct whilst maintaining search engine niceness?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

跨年 2024-08-05 13:54:33

我想问题是 - 你会重定向到哪里? 如果您重定向到域名,浏览器(或机器人)只会获取相同的旧 IP 地址并最终陷入重定向循环。

如果您重定向到 IP 地址……那么,这在某人的浏览器中看起来不太用户友好。

就我个人而言,我不会做任何事情。 机器人在尝试访问您的网站时可能会在短时间内出现错误,但这应该会在几天内自行解决,不会造成任何“SEO 损害”

I guess the question is - where would you redirect to? If you are redirecting to the domain name, the browser (or bot) would just get the same old IP address and end up in a redirect loop.

If you redirect to an IP address.. well, that's not going to look very user friendly in someone's browser.

Personally, I wouldn't do anything. There may be some short period where bots get errors trying to access your site, but it should all work itself out in a couple days without any "SEO damage"

日久见人心 2024-08-05 13:54:33

一种解决方案可能是使用 Mod_Proxy 而不是重写以将流量代理到新主机。 这样您就不会看到任何“SEO 损害”。

One solution might be to use Mod_Proxy instead of a rewrite to proxy traffic to the new host. This way you shouldn't see any "SEO damage".

物价感观 2024-08-05 13:54:33

我使用 rinetd 在 IP 级别将 IP 流量从旧服务器重定向到新服务器。 无需 Web 服务器或虚拟主机配置。 运行非常流畅并且对任何客户都绝对透明。

I used rinetd to redirect the IP traffic from the old server to the new one on IP level. No web server or virtual hosts config needed. Runs very smoothly and absolutely transparent to any client.

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