简体   繁体   English

在Rails中将域转发到子域

[英]Forward Domain to Subdomain in Rails

I would like to forward a domain to a particular subdomain (blog1.com --> blog1.example.com). 我想将域转发到特定的子域(blog1.com-> blog1.example.com)。

I have a Rails app that has a couple of subdomains. 我有一个具有两个子域的Rails应用程序。 I'm using constraints to manage the subdomain routes like this: 我正在使用约束来管理子域路由,如下所示:

#routes.rb

constraints :subdomain => "blog1" do
  root :to => "blog1#index"
end

constraints :subdomain => "blog2" do
  root :to => "blog2#index"
end

I've set up Heroku with a domain like example.com and added a wildcard domain through Heroku. 我已经使用例如example.com的域设置了Heroku,并通过Heroku添加了通配符域。 The subdomains work great. 子域效果很好。 I can get blog1.example.com without any issue. 我可以毫无问题地获得blog1.example.com。

I also added a cname (alias with dnsimple.com) from blog1.com --> blog1.example.com and added blog1.com as a domain on heroku. 我还从blog1.com-> blog1.example.com添加了一个cname(别名为dnsimple.com),并将blog1.com添加为heroku上的域。 But blog1.com doesn't catch the subdomain route. 但是blog1.com没有捕获子域路由。 Any suggestions to get the domain to respond? 有任何建议让网域回应吗?

i am not a dns expert, but i guess that you actually need to redirect in order for that to work. 我不是dns专家,但我想您实际上需要重定向才能正常工作。

otherwise you reach one domain through the other, but this is transparent for the server and the server is what matters in your case. 否则,您会通过另一个域到达一个域,但这对服务器是透明的,并且服务器对您而言很重要。

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

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