handling both http and https