如何在 Rails 中按域/子域进行路由

发布于 2024-08-21 12:39:23 字数 221 浏览 5 评论 0原文

我查看了 subdomain-fu ,看起来很容易将所有非 www 和非“”子域请求路由到单个控制器。

但我还需要将 CNAME 到我的域的所有外部域发送到同一控制器。我做了很多搜索,但找不到任何东西。

总之,如果它是我的域上的子域,它会转到 Catchall 控制器,如果它是我的域以外的任何其他域,它会转到同一个 Catchall 控制器。

我对此很着迷,任何帮助将不胜感激。

I looked at subdomain-fu and it looks pretty easy to route all non-www and non-'' subdomain requests to a single controller.

But I also, need to send all external domains that are CNAME'd to my domain to the same controller. I have done a lot of searching and I can't find anything.

Summarized, if it is a subdomain on my domain it goes to Catchall controller, if it is any other domain than my domain, it goes to the same Catchall controller.

I am going nuts on this, any help would be appreciated.

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

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

发布评论

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

评论(1

始于初秋 2024-08-28 12:39:23

您应该查看 request_routing 插件。它允许您轻松地通过以下方式路由请求:子域、域、方法、端口、remote_ip、content_type、协议等。

You should check out the request_routing plugin. It allows you to easily route request by: subdomain, domain, method, port, remote_ip, content_type, protocol, etc.

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