Redirect 'myapp.com' to 'www.myapp.com' in rails without using htaccess?

Posted by Allan L. on Stack Overflow See other posts from Stack Overflow or by Allan L.
Published on 2008-11-29T03:39:48Z Indexed on 2010/04/06 6:53 UTC
Read the original article Hit count: 375

Using Morph Labs' Appspace to deploy a site means no automated way to redirect 'myapp.com' to 'www.myapp.com' (and no access to .htacess).

Is there an in-rails way to do this? Would I need a plugin like subdomain-fu?

More specifically, I'm trying to do something like:

  • 'myapp.com' => 'www.myapp.com'
  • 'myapp.com/session/new' => 'www.myapp.com/session/new'

Basically, I always want the 'www' subdomain prepended on every request (because the SSL cert specifically has a common name of 'www.myapp.com').

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about .htaccess