discuz、ecshop、帝国cms部署https(ssl)后会员无法登录注意,以下教程只针对我司港台虚拟主机或者亚数的云主机香港IP部署SSL后的301跳转 1.discuz部署https后台无法登录: discuz采用: $_SERVER[‘HTTPS’] 方式判断,我司虚拟主机不支持同时也不支持$_SERVER['HTTP_HOST'],需使用$_SERVER['HTTP_FROM_HTTPS']进行判断,其他php程序同样适用。 source/class/discuz/discuz_application.php (第188行左右): 查找: $_G['isHTTPS'] = ($_SERVER['HTTPS'] && strtolower($_SERVER['HTTPS']) != 'off') ? true : false; 修改为: $_G['isHTTPS'] = ($_SERVER['HTTP_FROM_HTTPS'] && strtolower($_SERVER['HTTP_FROM_HTTPS']) != 'off') ? true : false; uc_server/avatar.php(第14行左右): 查找: define('UC_API', strtolower(($_SERVER['HTTPS'] == 'on' ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST'].substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/')))); 修改为: define('UC_API', strtolower(($_SERVER['SERVER_PORT'] == 443 || $_SERVER['HTTP_FROM_HTTPS'] == 'on' ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST'].substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/')))); 另:使用301方式强制将http跳转到https后会导致后台uc通信失败。 2.ecshop部署https后台无法登录: 打开includes/cls_ecshop.php 154行左右 查找 return (isset($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) != 'off')) ? 'https://' : 'http://'; 修改为: return isset($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) != 'off')||(strtolower($_SERVER['HTTP_FROM_HTTPS']) == 'on') ? 'https://' : 'http://'; 3.帝国cms部署https后台登陆空白 (1)帝国cms7.2及以下版本 e/class/connect.php function eReturnDomain(){ $domain=RepPostStr($_SERVER['HTTP_HOST'],1); if(emptyempty($domain)) { return ''; } // return 'http://'.$domain; 注释该行,替换成下两行内容 $httptype = isset($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) != 'off')||(strtolower($_SERVER['HTTP_FROM_HTTPS']) == 'on') ? 'https://' : 'http://'; return $httptype.$domain; } function FWeReturnDomain(){ $domain=RepPostStr($_SERVER['HTTP_HOST'],1); if(emptyempty($domain)) { return ''; } //return 'http://'.$domain; 注释该行,替换成下两行内容 $httptype = isset($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) != 'off')||(strtolower($_SERVER['HTTP_FROM_HTTPS']) == 'on') ? 'https://' : 'http://'; return $httptype.$domain; } (2)帝国cms7.5及以上版本 e/config/config.php 'httptype'=>0 # 全自动 e/class/connect.php function eCheckUseHttps(){ //if($_SERVER['HTTPS']&&strtolower($_SERVER['HTTPS'])!='off') 注释该行, 替换成下一行内容 if (isset($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) != 'off')||(strtolower($_SERVER['HTTP_FROM_HTTPS']) == 'on')) { return 1; } else { return 0; } }
|