Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm developing on Sites, and having trouble distinguishing whether the current request is coming in on HTTP or HTTPS. Do you have any tips?

// ==> relative url without the domain or protocol

// doesn't dependably include any url information
share|improve this question
Once you know whether it is HTTP or HTTPS, what do you plan to do? ;-) – bigassforce Mar 26 '14 at 17:05
Use a <page action={!actionFunction} to force the HTTP request to reload in HTTPS for a few particularly sensitive pages. – Benj Mar 26 '14 at 21:05
up vote 6 down vote accepted

You could use the URL class:

System.debug('URL Protocol: ' + URL.getSalesforceBaseUrl().getProtocol()); 
share|improve this answer
// Returns:
share|improve this answer
This would totally work, but I ended up going with Daniel's approach and its handy getProtocol shortcut – Benj Mar 26 '14 at 21:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.