diff --git a/app/index/controller/BaseController.php b/app/index/controller/BaseController.php index 7277cdd..1534bf1 100644 --- a/app/index/controller/BaseController.php +++ b/app/index/controller/BaseController.php @@ -4,17 +4,36 @@ namespace app\index\controller; use app\BaseController as AppBaseController; use app\common\Bootstrap; +use think\exception\HttpResponseException; +use think\facade\Request; use think\Paginator; class BaseController extends AppBaseController { - public function initialize() - { - parent::initialize(); + public function initialize() + { + parent::initialize(); - Paginator::maker(function($items, $listRows, $currentPage, $total, $simple, $options){ - return new Bootstrap($items, $listRows, $currentPage, $total, $simple, $options); - }); - - } + Paginator::maker(function ($items, $listRows, $currentPage, $total, $simple, $options) { + return new Bootstrap($items, $listRows, $currentPage, $total, $simple, $options); + }); + + $main_domain = get_system_config('main_domain'); + $url = Request::url(); + + if (!empty($main_domain)) { + if (Request::host() != $main_domain) { + + throw new HttpResponseException(redirect(Request::scheme() . '://' . $main_domain . '' . $url)); + } + } + + $is_jump_https = get_system_config('is_jump_https', 0); + + if ($is_jump_https == 1) { + if (Request::scheme() != 'https') { + throw new HttpResponseException(redirect('https://' . $main_domain . '' . $url)); + } + } + } } diff --git a/view/admin/system/index.html b/view/admin/system/index.html index 7278243..433706e 100644 --- a/view/admin/system/index.html +++ b/view/admin/system/index.html @@ -35,7 +35,7 @@
系统管理
-
+
网站名称
@@ -163,6 +163,13 @@ class="layui-input">
+
+
自动跳转https
+
+ + +
+
资源域名
@@ -214,9 +221,14 @@ {include file="common/_footer"}