https Redirect Problem

Asked

Viewed 473 times

5

I’m having a bit of a weird problem here.

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

It seems to me that some default setting is making the redirect to the site with HTTPS and I’m not getting the problem.

  • 2

    see if this stack overflow issue can resolve: http://stackoverflow.com/questions/11773544/nginx-different-domains-on-same-ip

  • 2

    Post to your configuration.

1 answer

2

I believe this will work. In php:

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

    Actually the question refers to Nginx, and has nothing to do with the implementation of one site or another. The question is language independent.

  • @Ciganomorrisonmendez This reminds me trying to solve a problem with Nginx poorly configured (I had no permissions to fix it) using files .htaccess.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.