gpt4 book ai didi

php - 为什么即使使用 https,PHP 的 "SERVER_PROTOCOL"也会显示 HTTP/1.1?

转载 作者:可可西里 更新时间:2023-10-31 22:41:40 24 4
gpt4 key购买 nike

地址栏显示“https://mywebsite.com”并显示一个锁定图标(点击它显示它是 AES-256),但是当我运行以下代码时,它总是打印“HTTP/1.1”。

echo $_SERVER[ "SERVER_PROTOCOL" ];

为什么不显示 https?

最佳答案

SERVER_PROTOCOL 与您页面的安全性无关,它报告所使用的连接是 HTTP 1.0、HTTP 1.1 还是 HTTP 2.0:

http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol

HTTP/1.1 is a revision of the original HTTP (HTTP/1.0). In HTTP/1.0 a separate connection to the same server is made for every resource request. HTTP/1.1 can reuse a connection multiple times to download images, scripts, stylesheets et cetera after the page has been delivered. HTTP/1.1 communications therefore experience less latency as the establishment of TCP connections presents considerable overhead.

虽然 HTTP 2.0 是下一代 HTTP,它允许在一个 HTTP 2.0 连接中多路复用多个 HTTP 1.1 连接。

为了您的目的,检查是否设置了 HTTPS 服务器变量:

http://php.net/manual/en/reserved.variables.server.php

即像

if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { ... }

关于php - 为什么即使使用 https,PHP 的 "SERVER_PROTOCOL"也会显示 HTTP/1.1?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16825243/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com