有些学建网站的学员使用Discuz建论坛网站时,遇到一个问题,在HTTP站点时UCenter通信是正常的,但启用了HTTPS站点后,UCenter通信失败。
出现HTTPS站点UCenter通信失败的原因是由于301重定向https后通信失败的。下面介绍一下解决方法。
方法/步骤
- 打开目录 uc_server/model/misc.php 文件;
- 在misc.php中搜索以下的代码:
$port = !empty($matches[‘port’]) ? $matches[‘port’] : 80;
- 在这段代码下面加上以下的代码:
if(substr($url,0,5)==’https’){
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if($post){
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}
if($cookie){
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
}
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
return curl_exec($ch);
} - 修改后,保存。上传替换掉原来的misc.php,即可解决Discuz开启HTTPS站点后UCenter通信失败的问题。