Set a redirect location.

@param string  $location The redirect location.
@param integer $status   The redirect HTTP status.
775258
public function redirect($location, $status = 302)
    {
        if (!$location) {
            return;
        }
        $this->status($status);
        $headers = $this->headers();
        $headers['Location'] = $location;
        return $this;
    }
117954
public function isRedirect(string $location = null): bool
    {
        return \in_array($this->statusCode, [201, 301, 302, 303, 307, 308]) && (null === $location ?: $location == $this->headers->get('Location'));
    }
1039560
public function redirect(string $location, int $code = Status::FOUND): self
    {
        $this->setStatus($code)->setHeader('Location', trim($location));

        return $this;
    }
92392
public static function setResponseStatus(int $status) : void
    {
        if (array_key_exists($status, Http::$http_status_messages)) {
            header('HTTP/1.1 ' . $status . ' ' . Http::$http_status_messages[$status]);
        }
    }
505819
public function redirectTo($location) {
        $app = $GLOBALS['app'];
        $host = $_SERVER['HTTP_HOST'];
        if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
            $host = $_SERVER['HTTP_X_FORWARDED_HOST'];
        }
        $protocol = isset($_SERVER['HTTPS'])?'https://':'http://'; 
        $redirectLocation = $protocol.$host.'/'.$app->getConfiguration()->getApplicationContext().'/'.$location;
        if ($app->getSubject()->isAuthenticated()) {
            $separator = '?';
            if(strpos($redirectLocation, '?'))
                $separator = '&';
            $redirectLocation .= $separator."rand_token=".urlencode($app->getSessionManager()->getActiveSession()->getAttribute('nonce'));
        }
        if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && 
            strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
                $this->addHeader("Content-type: application/json");
                $response = array();
                $response['redirect'] = $redirectLocation;
                echo json_encode($response);
                exit;
        } else {
            $this->addHeader('Location: '.$redirectLocation);
        }
    }
1221877
public function redirect($url = null, $statusCode = 302, $options = array())
    {
        $this->setStatusCode($statusCode);
        $this->setOption($options);

        // The variables for custom redirect view
        $escapedUrl = htmlspecialchars($url, ENT_QUOTES, 'UTF-8');
        $wait = (int)$this->redirectWait;

        // Location header does not support delay
        if (0 === $wait) {
            $this->setHeader('Location', $url);
        }

        // Prepare response content
        if ($this->redirectView) {
            ob_start();
            require $this->redirectView;
            $content = ob_get_clean();
        } else {
            $content = sprintf('<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="refresh" content="%d;url=%2$s">
    <title>Redirecting to %s</title>
  </head>
  <body>
    <h1>Redirecting to <a href="%2$s">%2$s</a></h1>
  </body>
</html>', $wait, $escapedUrl);
        }

        return $this->setContent($content);
    }
1189585
public static function redirect(string $url, bool $stop = true){
		header('Location: /'.$url);
  		if($stop)
			exit();
	}
680381
private function redirect($location)
    {
        $locationUrl = new Url($location);

        // if the location header was relative (bleh) add the host
        if (!$locationUrl->hasHost()) {
            $locationUrl = $this->url->getUrlForPath($location);
        }

        if ($this->redirects > self::MAXredirects) {
            throw new Error\BadRequest("Exceeded maximum redirects");
        }

        $this->redirects++;

        return $this->dispatchRequest(
            new Request('GET', $locationUrl, $this->headers)
        );
    }
221002
public function redirect($url, $status = 302)
    {
        $this->_headers['Location'] = (string) $url;
        $this->_status = (integer) $status;

        return $this;
    }
1345893
public static function redirect($location, $permanent = false)
    {
        $response = new self(
            $permanent ? Status::MOVED_PERMANENTLY : Status::SEE_OTHER,
            new StringStream('')
        );
        $response->setHeader('Location', $location);
        return $response;
    }
89784
protected function redirect($location, $status = 302, $headers = array()) {
		// Check if a output action has be already performed
		$this->_checkIfPerformed();

		// Create a redirect
		$redirectResponse = \Symfony\Component\HttpFoundation\RedirectResponse::create($location, $status, $headers);

		// Add request informationen
		$redirectResponse->prepare($this->application->requestStack->getCurrentRequest());

		// Replace response object
		$this->application->response = $redirectResponse;

		// Don't use a template
		$this->useTemplate(false, $status);
	}
930713
public void redirect(String location, int httpStatusCode) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Redirecting ({} to {}", httpStatusCode, location);
        }
        response.setStatus(httpStatusCode);
        response.setHeader("Location", location);
        response.setHeader("Connection", "close");
        try {
            response.sendError(httpStatusCode);
        } catch (IOException e) {
            LOG.warn("Exception when trying to redirect permanently", e);
        }
    }
1212922
public function setStatus($status)
    {
        if ($status && $this->enabled->get()) {
            try {
                $this->lastUpdate = time();
                $this->openSession($this->serverLogin->get(), $this->apikey->get());
            } catch (\Exception $e) {
                echo $e->getMessage();
            }
        }
    }
479233
public function redirect($url, $statusCode = 302)
    {
        if (strpos($url, '/') === 0 && strpos($url, '//') !== 0) {
            $url = request()->root() . $url;
        }

        $this->status($statusCode);
        $this->headers->set('Location', $url);
    }
870270
public function redirect($url, $status = 302)
    {
        if ($status != 302) {
            $this->setStatus($status);
        }
        $this->setHeader('Location', $url);
        $this->sendHeader();
    }
802319
public static function redirect(string $url, int $status = 302, int $delay = null)
    {
        // Status codes
        $messages = [];
        $messages[301] = '301 Moved Permanently';
        $messages[302] = '302 Found';

        // Is Headers sent ?
        if (headers_sent()) {
            echo "<script>document.location.href='" . $url . "';</script>\n";
        } else {

            // Redirect headers
            Http::setRequestHeaders('HTTP/1.1 ' . $status . ' ' . Arr::get($messages, $status, 302));

            // Delay execution
            if ($delay !== null) {
                sleep((int) $delay);
            }

            // Redirect
            Http::setRequestHeaders("Location: $url");

            // Shutdown request
            Http::requestShutdown();
        }
    }
429540
public function setStatus( $status )
	{
		if ( $status == $this->getStatus() ) { return; }

		$this->_values['status'] = (int) $status;
		$this->_modified = true;
	}