LINUX.ORG.RU

Капризный редирект.

 , ,


0

1

Добрый день. Подскажите пожалуйста почему site.com и https://site.com работают отдельно? вроде прописал rewrite и редирект должен работать? подскажите пожалуйста где косяк.

server {
            server_name site.com;
            keepalive_timeout    70;
            listen 80; # managed by Certbot
                        access_log off;
                        error_log on;
                        root /home/site.com/public_html;
                        error_log /home/site.com/logs/cirrus.error.log;
                        index index.php index.html index.htm;

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/site.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/site.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

server {
          listen   80;
          access_log off;
          error_log off;
          #error_log /home/site.com/logs/error.log;
          root /home/site.com/public_html;
          index index.php index.html index.htm;
          server_name site.com;
          rewrite ^ https://site.com$request_uri? permanent; #301 redirect;

#location / {

   # try_files $uri $uri/ /index.php?$query_string;

#}
###############################################################
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/site.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/site.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}