简体   繁体   中英

Forward Domain to Subdomain in Rails

I would like to forward a domain to a particular subdomain (blog1.com --> blog1.example.com).

I have a Rails app that has a couple of subdomains. 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. The subdomains work great. I can get blog1.example.com without any issue.

I also added a cname (alias with dnsimple.com) from blog1.com --> blog1.example.com and added blog1.com as a domain on heroku. But blog1.com doesn't catch the subdomain route. 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.

otherwise you reach one domain through the other, but this is transparent for the server and the server is what matters in your case.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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