开发者

Rails route based on virtual host (Host HTTP header)

开发者 https://www.devze.com 2023-03-05 20:10 出处:网络
Is it possible to specif开发者_开发问答y a Ruby on Rails route based on the host part of the request URL?

Is it possible to specif开发者_开发问答y a Ruby on Rails route based on the host part of the request URL?

In config/routes.rb, I have

root :to => 'entities#index'

but I would like to use the same code base to serve several sites, each with their own default controller.


You can use Request Base Constraints

root :to => "siteone#index", :constraints => {:host => "siteone"}
root :to => "sitetwo#index", :constraints => {:host => "sitetwo"}

Hope this helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消