mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
优化路由子域名支持
This commit is contained in:
@@ -85,6 +85,8 @@ return [
|
|||||||
'url_module_map' => [],
|
'url_module_map' => [],
|
||||||
// 域名部署
|
// 域名部署
|
||||||
'url_domain_deploy' => false,
|
'url_domain_deploy' => false,
|
||||||
|
// 域名根,如.thinkphp.cn
|
||||||
|
'url_domain_root' => '',
|
||||||
// 域名部署规则
|
// 域名部署规则
|
||||||
'url_domain_rules' => [],
|
'url_domain_rules' => [],
|
||||||
|
|
||||||
|
|||||||
@@ -163,6 +163,11 @@ class Route
|
|||||||
// 检测子域名部署
|
// 检测子域名部署
|
||||||
public static function checkDomain()
|
public static function checkDomain()
|
||||||
{
|
{
|
||||||
|
// 检测是否开启子域名支持
|
||||||
|
if(!Config::get('url_domain_deploy')) return;
|
||||||
|
$root = Config::get('url_domain_root');
|
||||||
|
// 检测是否配置域名根
|
||||||
|
if(empty($root)) return;
|
||||||
$rules = self::$domain;
|
$rules = self::$domain;
|
||||||
// 开启子域名部署 支持二级和三级域名
|
// 开启子域名部署 支持二级和三级域名
|
||||||
if (!empty($rules)) {
|
if (!empty($rules)) {
|
||||||
@@ -171,7 +176,8 @@ class Route
|
|||||||
$rule = $rules[$_SERVER['HTTP_HOST']];
|
$rule = $rules[$_SERVER['HTTP_HOST']];
|
||||||
} else {
|
} else {
|
||||||
// 子域名配置
|
// 子域名配置
|
||||||
$domain = array_slice(explode('.', $_SERVER['HTTP_HOST']), 0, -2);
|
$domain = rtrim(rtrim($_SERVER['HTTP_HOST'], $root), '.');
|
||||||
|
$domain = explode('.', $domain);
|
||||||
if (!empty($domain)) {
|
if (!empty($domain)) {
|
||||||
$subDomain = implode('.', $domain);
|
$subDomain = implode('.', $domain);
|
||||||
$domain2 = array_pop($domain); // 二级域名
|
$domain2 = array_pop($domain); // 二级域名
|
||||||
|
|||||||
Reference in New Issue
Block a user