鍍金池/ 問答/PHP  Linux  網絡安全  HTML/ 為啥https會自動301跳轉到http?

為啥https會自動301跳轉到http?

有個站點,剛剛成功的安裝了 Let’s Encrypt 的免費證書,nginx已經配置了關于https的訪問。

現(xiàn)在可以通過 https 和 http 兩種方式訪問了,有些頁面兩種方式都可以訪問,但是部分頁面通過https訪問竟然會 301 跳轉到 http 頁面地址,例如:

https://www.phpernote.com/php-template/200.html

這是為什么呢?請各位大神各抒己見,多謝!

nginx 配置如下:

server {
        listen       80;
        server_name  www.phpernote.com ;
        root   /home/xxx/xxx;
        location / {
            index  index.php index.html;
        }
        include /home/xxx/xxx/.htaccess;
        location ~ ^(?:(?<!\.php).)+\.php($|/.*) {
            fastcgi_pass unix:/tmp/php-cgi.sock;
            fastcgi_index  index.php;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }
}

server {
        listen       80;
        server_name  phpernote.com ;
        root   /home/xxx/xxx;
        location / {
            index  index.php index.html;
        }
        include /home/xxx/xxx/.htaccess;
        location ~ ^(?:(?<!\.php).)+\.php($|/.*) {
            fastcgi_pass unix:/tmp/php-cgi.sock;
            fastcgi_index  index.php;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }
}

server {
        listen       443 ssl;
        ssl on;
        ssl_certificate /etc/letsencrypt/live/www.phpernote.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/www.phpernote.com/privkey.pem;
        server_name  www.phpernote.com ;
        root   /home/xxx/xxx;
        location / {
            index  index.php index.html;
        }
        include /home/xxx/xxx/.htaccess;
        location ~ ^(?:(?<!\.php).)+\.php($|/.*) {
            fastcgi_pass unix:/tmp/php-cgi.sock;
            fastcgi_index  index.php;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }
}
回答
編輯回答
蝶戀花

配置信息應該沒問題,
include /home/xxx/xxx/.htaccess;
這里有什么特殊的配置?

更改配置后有 重啟nginx 么

2017年7月23日 12:28