Reputation: 32223
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/
Upvotes: 2
Views: 1018
Reputation: 1269
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)}
Upvotes: 4