Try to detect whether to redirect to https or http