public
Last active

rack-rewrite for yesWWW (require www in url)

  • Download Gist
production.rb
Ruby
1 2 3 4 5 6 7
ExampleApp::Application.configure do
# Requires rack-rewrite: https://github.com/jtrupiano/rack-rewrite
config.middleware.insert_before(Rack::Lock, Rack::Rewrite) do
r301 /.*/, Proc.new {|path, rack_env| "http://www.#{rack_env['SERVER_NAME']}#{path}" }, :if => Proc.new {|rack_env| rack_env['SERVER_NAME'] !~ /www\./i}
end
#... the rest of production environment config.
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.