tp框架识别不了https兼容处理

This commit is contained in:
devil_gong 2019-03-14 15:44:45 +08:00
parent e34a65e3e1
commit 8064f66636
2 changed files with 7 additions and 1 deletions

View File

@ -225,6 +225,12 @@ function MyUrl($path, $params=[])
$url = str_replace('public/', '', $url);
}
// tpurl方法是否识别到https
if(__MY_HTTP__ == 'https' && substr($url, 0, 5) != 'https')
{
$url = 'https'.mb_substr($url, 4, null, 'utf-8');
}
return $url;
}

View File

@ -19,7 +19,7 @@ define('APPLICATION_VERSION', 'v1.4.0');
define('DS', '/');
// HTTP类型
define('__MY_HTTP__', ((!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') || (!empty($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off')) ? 'https' : 'http');
define('__MY_HTTP__', ((!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') || (!empty($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off') || (!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) || (!empty($_SERVER['HTTP_FROM_HTTPS']) && $_SERVER['HTTP_FROM_HTTPS'] !== 'off')) ? 'https' : 'http');
// 根目录
$my_root = empty($_SERVER['SCRIPT_NAME']) ? '' : substr($_SERVER['SCRIPT_NAME'], 1, strrpos($_SERVER['SCRIPT_NAME'], '/'));