, :
class ApplicationController < ActionController::Base
before_filter :redirect_to_example if Rails.env.production?
protect_from_forgery with: :exception
private
def redirect_to_example
domain_to_redirect_to = 'example.com'
domain_exceptions = ['example.com', 'www.example.com']
should_redirect = !(domain_exceptions.include? request.host)
new_url = "#{request.protocol}#{domain_to_redirect_to}#{request.fullpath}"
redirect_to new_url, status: :moved_permanently if should_redirect
end
end
domain_to_redirect_to, , domain_exceptions.
source
share