【实测】DZ网站设置https加密证书后uc_server通信失败完美解决方法
        
        
        
 
                        
    
		
Discuz建论坛网站时,遇到一个问题,在HTTP站点时UCenter通信是正常的,但启用了HTTPS站点后,UCenter通信失败。 
 
修改前: 
 
 
修改后: 
 
 
出现HTTPS站点UCenter通信失败的原因是由于301重定向https后通信失败的。下面介绍一下解决方法。 
 
解决方法如下: 
1、进入网站根目录——uc_server——model——misc.php 文件; 
2、搜索以下的代码- $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);
 
 -                 }
 
 
  复制代码 3、修改后,保存。即可解决Discuz开启HTTPS站点后UCenter通信失败的问题。 
 
 |   
            
        
 
  
        
        
  | 
| 
        
 | 
| 
 | 
| 
 |