Created
June 26, 2015 16:46
-
-
Save ChrisLTD/c59775288e321de76028 to your computer and use it in GitHub Desktop.
Apex domain redirect in Rails 4
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 ApplicationController < ActionController::Base | |
| # Prevent CSRF attacks by raising an exception. | |
| # For APIs, you may want to use :null_session instead. | |
| protect_from_forgery with: :exception | |
| before_filter :check_domain_and_ssl | |
| def check_domain_and_ssl | |
| if Rails.env.production? and (request.protocol.downcase + request.host.downcase) != 'https://www.mywebsite.com' | |
| redirect_to 'https://www.mywebsite.com' + request.fullpath | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment