2

What's the best way to redirect all your pages from www to root domain using ruby on rails?

keruilin
  • 16,782
  • 34
  • 108
  • 175

2 Answers2

2

Sometimes your host won't let you do redirects, so I think it's ok practice to do it either in your application_controller or middleware. If you're on Rails3, check out this no-www gem

This SO Question has examples of going from www to no-www and from no-www to www.

Community
  • 1
  • 1
Jesse Wolgamott
  • 40,197
  • 4
  • 83
  • 109
1

Does it have to be in Rails? This is pretty easy to do with Apache, for instance.

http://txt.binnyva.com/2008/09/remove-www-from-url-using-htaccess-in-apache/

Robert Speicher
  • 15,382
  • 6
  • 40
  • 45