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

Popular posts from this blog

qt - switch/case statement in C++ with a QString type -

python - sqlite3.OperationalError: near "REFERENCES": syntax error - foreign key creating -

Python's equivalent for Ruby's define_method? -