rails 3 - one app, multiple domains, how implement a different 'root' route for one of the domains?

后端 未结 1 868
长发绾君心
长发绾君心 2021-02-06 09:46

Several different domains names point to my app on heroku, for example foo.com and bar.com both point to the app. (We host specialized blog pages, and foo.com is the domain used

相关标签:
1条回答
  • 2021-02-06 10:03

    I usually proceed as follows:

    constraints(Subdomain) do
      match "/" => "home#admin"
    end
    
    match "/" => "home#standard" 
    

    Or:

    match "/" => "home#admin", :constraints => {:subdomain => "admin"}
    
    match "/" => "home#standard" 
    

    Which creates:

    /(.:format) {:action=>"admin", :subdomain=>"admin", :controller=>"home"}
    root  /(.:format) {:action=>"standard", :controller=>"home"}
    

    The same logic lets you create routes only available to desired subdomains.

    0 讨论(0)
提交回复
热议问题