Is there a way to redirect www.foo.com/* to foo.com/* using Ruby on Rails without mod_rewrite -


I want to redirect any request from www.foo.com to foo.com Generally, I use mod_rewrite to do this and just use a regular expression to match any subdomain However, I am using Heroes to host this application, which I I can tell, I do not give this capability.

Is there an easy way to do this in Ruby on Rails? Thanks!

You can add a before_filter to your ApplicationController

  class ApplicationController & Lt; ActionController :: Base before_filter: redirect_www def redirect_www if /www/.match (request.host) redirect_to request.protocol + request.host_with_port + request.request_uri End End    

Comments