简体   繁体   English

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

[英]How do I route by domain / subdomain in rails

I looked at subdomain-fu and it looks pretty easy to route all non-www and non-'' subdomain requests to a single controller. 我看了subdomain-fu,将所有非www和non-''子域请求路由到单个控制器看起来很容易。

But I also, need to send all external domains that are CNAME'd to my domain to the same controller. 但是我还需要将所有CNAME到我的域的外部域发送到同一控制器。 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. 总结一下,如果它是我域中的子域,它将转到Catchall控制器;如果它是我域中以外的任何其他域,则它将转到同一Catchall控制器。

I am going nuts on this, any help would be appreciated. 我对此很不满意,任何帮助将不胜感激。

You should check out the request_routing plugin. 您应该签出request_routing插件。 It allows you to easily route request by: subdomain, domain, method, port, remote_ip, content_type, protocol, etc. 它使您可以轻松地通过以下方式路由请求:子域,域,方法,端口,remote_ip,content_type,协议等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM