private function resolveCurrent()
    {
        $requestPath = $this->request->get('path', null);

        if (empty($requestPath)) {
            $home = $this->getHome();
            if (!$home) {
                throw new NotFoundHttpException('Home item could not be found, have you forget to set a default page?');
            }
            $requestPath = $home->alias;
        }

        $requestPath = rtrim($requestPath, '/');
        
        $urlParts = explode('/', $requestPath);
        
        $item = $this->aliasMatch($urlParts);

        if (!$item) {
            while (array_pop($urlParts)) {
                if (($item = $this->aliasMatch($urlParts, true)) !== false) {
                    break;
                }
            }
        }

        if ($item) {
            $this->_currentAppendix = substr($requestPath, strlen($item->alias) + 1);
            return $item;
        }

        // no item could have been resolved, but the home side type is module, which can have links.
        if (!$item && $this->home->type == 2) {
            $this->_currentAppendix = $requestPath;
            return $this->getHome();
        }
        
        // we could not resolve a page, check if the website has customized 404 error page defined.
        $navId = Config::get(Config::HTTP_EXCEPTION_NAV_ID, 0);
        $menu = Yii::$app->menu->find()->with(['hidden'])->where(['nav_id' => $navId])->one();
        if ($menu) {
            $menu->is404Page = true;
            return $menu;
        }

        throw new NotFoundHttpException("Unable to resolve requested path '".$requestPath."'.");
    }