301重定向http至https后导致站点与UCenter通信失败的解决方法 - 任刚 · Ren Gang - 我的设计笔记 世界设计 · 设计世界

在Ucenter目录找到 uc_server/model/misc.php 这个文件;

用DreamWeaver在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文件,然后在Ucenter后台更新缓存,大功告成。

" /> 301重定向http至https后导致站点与UCenter通信失败的解决方法 · 任刚 · Ren Gang - 我的设计笔记

301重定向http至https后导致站点与UCenter通信失败的解决方法

, , , , , ,
16/05/2019    任刚    小贴士

在腾讯云申请了SSL证书,通过301重定向实现全站https,但是问题来了,全站https后网站与UCenter通信失败,下面是解决办法:

301重定向http至https后导致站点与UCenter通信失败的解决方法 - 任刚 · Ren Gang - 我的设计笔记 世界设计 · 设计世界

在Ucenter目录找到 uc_server/model/misc.php 这个文件;

用DreamWeaver在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文件,然后在Ucenter后台更新缓存,大功告成。

「真诚赞赏,手留余香」

任刚 rengang.com.cn

赞助用于本站维护,手机长按识别二维码。

任刚(rengang.com.cn)整理分享,欣赏作品版权均归原作者所有,仅供学习交流。点击上方图标与好友分享!


发表回复

登 录 注 册