Skip to content

Instantly share code, notes, and snippets.

@joshdholtz
Created March 14, 2012 13:20
Show Gist options
  • Save joshdholtz/2036403 to your computer and use it in GitHub Desktop.
Save joshdholtz/2036403 to your computer and use it in GitHub Desktop.
Padrino Component - Redirect request from WWW to non-WWW
class App < Padrino::Application
...
register WWWRedirect
...
end
module WwwRedirect
def self.registered(app)
app.before do
redirect request.url.sub(/www\./, ''), 301 if request.host =~ /^www/
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment