php 获取当前访问URL的协议
<?php $slhttp = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';
echo $slhttp;
?>
nginx proxy-pass-php.conf 配置
location @apache
{
internal;
proxy_pass http://127.0.0.1:88;
proxy_set_header X-Forwarded-Proto $scheme;
incldue proxy.conf;
}
location ~ [^/]\.php(/|$)
{
proxy_set_header X-Forwarded-Proto $scheme;
}
来自 https://www.cnblogs.com/maoxianfei/p/9989324.html
PHP获取请求协议类型听语音
|
浏览:918
|
更新:
区分HTTP和HTTPS
方法/步骤
- 1
$protocol = empty($_SERVER['HTTP_X_CLIENT_PROTO']) ? 'http:' : $_SERVER['HTTP_X_CLIENT_PROTO'] . ':';
- 2
如果检测不到 $_SERVER['HTTP_X_CLIENT_PROTO'] 就可以说明没有开启HTTPS, 就是HTTP请求
END
来自 https://jingyan.baidu.com/article/f0e83a25935dfb22e591018d.html