Created
March 14, 2012 13:20
-
-
Save joshdholtz/2036403 to your computer and use it in GitHub Desktop.
Padrino Component - Redirect request from WWW to non-WWW
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class App < Padrino::Application | |
... | |
register WWWRedirect | |
... | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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