discuz、ecshop部署https(ssl)后会员无法登录
注意,以下教程只针对我司港台虚拟主机或者亚数的云主机香港IP部署SSL后的301跳转
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通信失败。
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://';