解决方法
Rails 3.0具有内置的此功能,您可以从request.subdomain访问子域.
您也可以根据子域路由:
class SupportSubdomain def self.matches?(request) request.subdomain == "support" end end Basecamp::Application.routes do constraints(SupportSubdomain) do match "/foo/bar",:to => "foo#bar" end end
如果你使用2.3,你需要使用一个插件,如subdomain-fu.