为啥https会自动301跳转到http?

有个站点,刚刚成功的安装了 Let’s Encrypt 的免费证书,nginx已经配置了关于https的访问。

现在可以通过 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;
        }
}
阅读 6.9k
1 个回答

配置信息应该没问题,
include /home/xxx/xxx/.htaccess;
这里有什么特殊的配置?

更改配置后有 重启nginx 么

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题