Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class NoWWW
- STARTS_WITH_WWW = /^www\./i
- def initialize(app)
- @app = app
- end
- def call(env)
- if env['HTTP_HOST'] =~ STARTS_WITH_WWW
- [301, { 'Location' => Rack::Request.new(env).url.sub(/www\./i, '') }, ['Redirecting...']]
- else
- @app.call(env)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement