开发者

Rails route based on virtual host (Host HTTP header)

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜