Skip to content

Instantly share code, notes, and snippets.

@kvirani
Created September 5, 2012 18:55
Show Gist options
  • Save kvirani/3642524 to your computer and use it in GitHub Desktop.
Save kvirani/3642524 to your computer and use it in GitHub Desktop.
require ssl without apache on localhost
def require_ssl
if request.protocol != SECURE_PROTOCOL
redirect_to :protocol => SECURE_PROTOCOL
else # development or test
logger.info "redirected to ssl"
end
end
SECURE_PROTOCOL = 'http://' # this will be HTTPS for staging/prod
SECURE_PROTOCOL = 'https://' # This will be HTTP for dev/test
SECURE_PROTOCOL = 'https://' # This will be HTTP for dev/test
SECURE_PROTOCOL = 'http://' # This will be HTTP for dev/test
@kvirani
Copy link
Author

kvirani commented Sep 5, 2012

Subsequently, your internal page links that should switch to HTTPS can use the SECURE_PROTOCOL instead of 'https://' directly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment