Skip to content

Instantly share code, notes, and snippets.

@jordanandree
Forked from jfernandez/config.ru
Created July 6, 2012 02:41
Show Gist options
  • Save jordanandree/3057752 to your computer and use it in GitHub Desktop.
Save jordanandree/3057752 to your computer and use it in GitHub Desktop.
require 'rack-rewrite'
DOMAIN = 'www.production-hacks.com' # also works with non-www url such as 'google.com'
# Redirect to the www version of the domain in production
use Rack::Rewrite do
r301 %r{.*}, "http://#{DOMAIN}$&", :if => Proc.new {|rack_env|
rack_env['SERVER_NAME'] != DOMAIN && ENV['RACK_ENV'] == "production"
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment