Detect HTTPS properly