daily pastebin goal
25%
SHARE
TWEET

Untitled

a guest Apr 19th, 2018 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class NoWWW
  2.  
  3.   STARTS_WITH_WWW = /^www\./i
  4.  
  5.   def initialize(app)
  6.     @app = app
  7.   end
  8.  
  9.   def call(env)
  10.     if env['HTTP_HOST'] =~ STARTS_WITH_WWW
  11.       [301, { 'Location' => Rack::Request.new(env).url.sub(/www\./i, '') }, ['Redirecting...']]
  12.     else
  13.       @app.call(env)
  14.     end
  15.   end
  16.  
  17. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top