public function redirectUrl($url = null)
    {
        $redirectUrl = $this->getController()->getRequest()->getQuery(static::QUERY_STRING_REDIRECT);
        if ($redirectUrl && (substr($redirectUrl, 0, 1) !== '/' || substr($redirectUrl, 0, 2) === '//')) {
            $redirectUrl = null;
        }

        if ($url !== null) {
            $redirectUrl = $url;
        } elseif ($redirectUrl) {
            if (Router::normalize($redirectUrl) === Router::normalize($this->_config['loginAction'])) {
                $redirectUrl = $this->_config['loginRedirect'];
            }
        } elseif ($this->_config['loginRedirect']) {
            $redirectUrl = $this->_config['loginRedirect'];
        } else {
            $redirectUrl = '/';
        }
        if (is_array($redirectUrl)) {
            return Router::url($redirectUrl + ['_base' => false]);
        }

        return $redirectUrl;
    }