Rails - How to Redirect from http://example.com to https://www.example.com -
i'm looking learn how cleanup app's urls. app powered rails 3 on heroku.
the desired url https://www.example.comite.com
i'd redirect urls unlike above url. rails thing or dns?
bad urls:
https://example.comite.com http://www.example.comite.com http://example.comite.com
and if trailing, http://www.example.comite.com/photo/1
url redirected path: https://www.example.comite.com/photo/1
dns records cannot define protocol domain, therefore can't redirect http://
https://
through dns. doing through web server configuration not portable, hard do, error prone , plain outdated. job best handled rails router.
# beginning of routes.rb match "*path" => redirect("https://www.mysite.com/%{path}"), :constraints => { :protocol => "http://" } match "*path" => redirect("https://www.mysite.com/%{path}"), :constraints => { :subdomain => "" }
Comments
Post a Comment