Skip to content

Instantly share code, notes, and snippets.

@nathanbertram
Created April 22, 2009 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathanbertram/99966 to your computer and use it in GitHub Desktop.
Save nathanbertram/99966 to your computer and use it in GitHub Desktop.
# The lazy man way to force www if you don't want to touch apache configs
def force_www
redirect_to "http://www.#{request.env['HTTP_HOST']}#{request.env['PATH_INF0']}" unless request.env['SERVER_NAME'] =~ /^www./
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment