Skip to content

Instantly share code, notes, and snippets.

@kurioscreative
Created February 16, 2012 07:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurioscreative/1843097 to your computer and use it in GitHub Desktop.
Save kurioscreative/1843097 to your computer and use it in GitHub Desktop.
rack-rewrite for yesWWW (require www in url)
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
@snuggs
Copy link

snuggs commented Sep 30, 2013

Nice work man!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment