支持 Rails 中的多个域/子域 [英] Support for multiple domains/subdomains in Rails

查看:25
本文介绍了支持 Rails 中的多个域/子域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Rails 应用程序,它的设置与 Tumblr 类似,也就是说,您可以选择:(1) 子域托管 (your-username.myapp.com)(2) 域名托管(your-username.com)

I have a Rails app that has a similar setup to Tumblr, that is, you can have either: (1) Subdomain hosting (your-username.myapp.com) (2) Domain hosting (your-username.com)

两者都会转发到该用户的个性化网站,该网站是用我的应用程序创建的.

Both would forward to a personalized website for that user, created with my application.

我怎样才能在 Rails 中做到这一点?我已经能够让 (1) 使用 subdomain-fu,但我不确定如何让 (2) 工作.任何指针(插件、宝石、教程)等都会有很大帮助,我似乎找不到.

How can I accomplish this in Rails? I have been able to get (1) working with subdomain-fu, but I'm not sure how to get (2) working. Any pointers (plugins, gems, tutorials), etc. would be greatly helpful, I can't seem to find any.

谢谢!

推荐答案

域的原理和子域一样——查找域,映射到一个帐户.

The principle for domains is the same as the subdomain - find the domain, map to an account.

详细信息取决于您的主机将如何处理 DNS.

The details will depend on how your hosting is going to handle the DNS.

我目前正在使用 Heroku 及其通配符服务.在这种情况下,域使用 cname 映射到由我的 Heroku 应用程序托管的子域.从这里我可以计算出关联的帐户和详细信息.

I am currently using Heroku and its wildcard service. In this case, the domain is mapped with a cname to the subdomain hosted by my Heroku app. From here I can work out the associated account and details.

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

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