2

I want to redirect my rails app to add www to the url if the user doesn't use it. I found this site to remove it, but I would like to do the opposite:

http://steve.dynedge.co.uk/2010/03/03/using-rackrewrite-to-remove-the-www/

NotDan
  • 31,709
  • 36
  • 116
  • 156

1 Answers1

4

Can you not just do something like this?

  r301 /.*/,  Proc.new {|path, rack_env| "http://www.#{rack_env['SERVER_NAME']}#{path}" },
    :if => Proc.new {|rack_env| ! (rack_env['SERVER_NAME'] =~ /www\./i)}
allan
  • 1,269
  • 9
  • 7