如何在 rails 中按域/子域路由 [英] How do I route by domain / subdomain in rails

查看:23
本文介绍了如何在 rails 中按域/子域路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

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.

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

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.

推荐答案

您应该查看 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.

这篇关于如何在 rails 中按域/子域路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆