问题描述 Discuz!部分页面提示不安全的HTTPS
解决思路 找出所有没使用HTTPS的文件的链接
解决办法
1)查找修改文件discuz_application.php
• 找到 source/class/discuz/discuz_application.php (约第187行处)
- $_G['isHTTPS'] = ($_SERVER['HTTPS'] && strtolower($_SERVER['HTTPS']) != 'off') ? true : false;
複製代碼修改为 - $_G['isHTTPS'] = ($_SERVER['SERVER_PORT'] == 443 || $_SERVER['HTTPS'] && strtolower($_SERVER['HTTPS']) != 'off') ? true : false;
複製代碼
2)查找修改文件
• 找到 uc_server/avatar.php (约第13行处)
- define('UC_API', strtolower(($_SERVER['HTTPS'] == 'on' ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST'].substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/'))));$_G['isHTTPS'] = ($_SERVER['HTTPS'] && strtolower($_SERVER['HTTPS']) != 'off') ? true : false;
複製代碼
修改为
- define('UC_API', strtolower(($_SERVER['SERVER_PORT'] == 443 || $_SERVER['HTTPS'] == 'on' ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST'].substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/'))));$_G['isHTTPS'] = ($_SERVER['SERVER_PORT'] == 443 || $_SERVER['HTTPS'] && strtolower($_SERVER['HTTPS']) != 'off') ? true : false;
-
複製代碼
3)查找修改文件admin.php
• 找到 uc_server/admin.php (约第13行处)
- define('UC_API', strtolower((isset($_SERVER['HTTPS']) && $_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['HTTPS'] == 'on' ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST'].substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/'))));
複製代碼
4)修改后台设置
• 后台 >全局 > 站点 URL,改为HTTPS
• 后台 > 站长 > UCenter 设置 > UCenter 访问地址,改为HTTPS
• UCenter 后台 > 应用管理 > 应用的主 URL,改为HTTPS
• 做到这一步还有问题,逐步排查模板、数据库等地方
|