Is it possible to specify 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With