Virtual hosting within one application (with lighttpd)


I’ve found plenty of descriptions of hosting multiple applications on
different virtual hosts using lighttpd and apache however, I’d like to
have a single Rails application but route different controllers to the
document root depending upon the requested hostname. (And in case you’re
wondering why anyone would want to do such a thing, it’s because I would
like web site on www and a WAP site on wap which use different
controllers but share the same model and a lot of other code).

I’ve tried lighttpd’s mod_rewrite but, while it rewrites the URL
internally, when it gets passed to Rails, the requested URI isn’t
rewritten so Rails always sees ‘’ when requesting the root document.

I’ve tried looking at routes.rb but as far as I can tell, there’s no way
to create a route based on server name.


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs