public static function urlToPath($url)
    {
        $baseUrl = Yii::$app->request->hostInfo;
        $parsedUrl = parse_url($url);
        if (isset($parsedUrl['host']) && !strpos($baseUrl, $parsedUrl['host'])) {
            return false;
        }
        if (!isset($parsedUrl['path'])) {
            return false;
        }
        $path = str_replace('/' . basename(Yii::$app->request->scriptFile), '', $parsedUrl['path']);
        $request = self::$_request ? self::$_request : (self::$_request = new Request());
        $request->setPathInfo($path);
        $rule = explode('/', Yii::$app->urlManager->parseRequest($request)[0]);

        if (count($rule) == 2) {
            array_unshift($rule, Yii::$app->id);
        }
        if (count($rule)!=3) {
            return false;
        }
        return array_combine(['module', 'controller', 'action'], $rule);
    }
public static function urlToPath($url)
    {
        $baseUrl = Yii::$app->request->hostInfo;
        $parsedUrl = parse_url($url);
        if (isset($parsedUrl['host']) && !strpos($baseUrl, $parsedUrl['host'])) {
            return false;
        }
        if (!isset($parsedUrl['path'])) {
            return false;
        }
        $path = str_replace('/' . basename(Yii::$app->request->scriptFile), '', $parsedUrl['path']);
        $request = self::$_request ? self::$_request : (self::$_request = new Request());
        $request->setPathInfo($path);
        $rule = explode('/', Yii::$app->urlManager->parseRequest($request)[0]);

        if (count($rule) == 2) {
            array_unshift($rule, Yii::$app->id);
        }
        if (count($rule)!=3) {
            return false;
        }
        return array_combine(['module', 'controller', 'action'], $rule);
    }
public static function urlToPath ( $ url ) { $ baseUrl = Yii :: $ app -> request -> hostInfo ; $ parsedUrl = parse_url ( $ url ) ; if ( isset ( $ parsedUrl [ 'host' ] ) && ! strpos ( $ baseUrl , $ parsedUrl [ 'host' ] ) ) { return false ; } if ( ! isset ( $ parsedUrl [ 'path' ] ) ) { return false ; } $ path = str_replace ( '/' . basename ( Yii :: $ app -> request -> scriptFile ) , '' , $ parsedUrl [ 'path' ] ) ; $ request = self :: $ _request ? self :: $ _request : ( self :: $ _request = new Request ( ) ) ; $ request -> setPathInfo ( $ path ) ; $ rule = explode ( '/' , Yii :: $ app -> urlManager -> parseRequest ( $ request ) [ 0 ] ) ; if ( count ( $ rule ) == 2 ) { array_unshift ( $ rule , Yii :: $ app -> id ) ; } if ( count ( $ rule ) != 3 ) { return false ; } return array_combine ( [ 'module' , 'controller' , 'action' ] , $ rule ) ; }
Gets router rule for url.
@param string $url url
@return mixed boolean or array [module, controller, action] ids.
Gets router rule for url .