Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
rack-rewrite for yesWWW (require www in url)
ExampleApp::Application.configure do
# Requires rack-rewrite:
config.middleware.insert_before(Rack::Lock, Rack::Rewrite) do
r301 /.*/, {|path, rack_env| "http://www.#{rack_env['SERVER_NAME']}#{path}" }, :if => {|rack_env| rack_env['SERVER_NAME'] !~ /www\./i}
#... the rest of production environment config.

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