Updated to allow SSL connections in redirect