https redirect problem

5

I have a rather bizarre problem here.

We have two sites on the same server running with Nginx ; one has HTTPS certificate and the other does not. The problem is that if a client enters the site without the certificate and places the HTTPS in it, the site is redirected to the other domain that has HTTPS . And if I happen to put the IP of the server, by default it goes to the domain that does not have HTTPS . However, if you put HTTPS before IP as well, the IP is redirected to the site that has HTTPS .

It seems to me that some default setting is redirecting to the site with HTTPS and I can not see the problem.

    
asked by anonymous 07.03.2014 / 15:05

1 answer

2

I believe this works. In php:

if($_SERVER['HTTPS'] == 'on'){
     $url = 'http://urldapagina.com.br' . $_SERVER['REQUEST_URI'];
     header("Location: $url");
     exit; 
}
    
07.03.2014 / 22:55