public function redirect($code, $nb_site_target, $nb_language = null, $params = null)
    {
        global $NABU_HTTP_CODES;

        if (is_string($nb_site_target)) {
            $url = new CNabuURL($nb_site_target);
            if (!$url->isValid()) {
                $nb_site_target = CNabuSiteTarget::findByKey($this, $nb_site_target);
                unset($url);
            }
        } elseif (is_numeric($nb_site_target)) {
            $nb_site_target = new CNabuSiteTarget($nb_site_target);
            if ($nb_site_target->isNew()) {
                $nb_site_target = null;
            }
        } elseif ($nb_site_target instanceof CNabuDataObject) {
            if (!($nb_site_target instanceof CNabuSiteTarget)) {
                $nb_site_target = new CNabuSiteTarget($nb_site_target);
                if ($nb_site_target->isNew()) {
                    $nb_site_target = null;
                }
            }
        } else {
            $nb_site_target = null;
        }

        if ($nb_site_target != null) {
            $encoded = '';
            if ($params != null && count($params) > 0) {
                foreach ($params as $field => $value) {
                    $encoded .= (strlen($encoded) > 0 ? "&" : "").urlencode($field)."=".urlencode($value);
                }
                $encoded = '?'.$encoded;
            }

            $nb_language_id = nb_getMixedValue($nb_language, 'nb_language_id');
            $nb_site = $this->nb_request->getSite();
            if ($nb_language_id == null) {
                $nb_language_id = $nb_site->getDefaultLanguageId();
            }

            $url = ($nb_site_target instanceof CNabuSiteTarget
                   ? $nb_site_target->getFullyQualifiedURL($nb_language_id) . $encoded
                   : $nb_site_target);
            throw new ENabuRedirectionException($code, $url);
        } elseif (isset($url)) {
            throw new ENabuRedirectionException($code, $url->getURL());
        } else {
            $this->http_response_code = 500;
            throw new ENabuCoreException(ENabuCoreException::ERROR_REDIRECTION_TARGET_NOT_VALID);
        }
    }