Send a "Location" header (redirect) pointing to the specified URI. Afterwards the script is terminated.

@param  string $uri - absolute or relative URI
@param  int    $type - redirect type: 301 (SC_MOVED_PERMANENTLY) or 302 (SC_MOVED_TEMPORARILY)
961548
public function redirect($uri, $type=HttpResponse::SC_MOVED_TEMPORARILY) {
        $request    = Request::me();
        $currentUrl = $request->getUrl();

        // HTTP/1.1 requires an absolute 'Location' value
        $url = self::relativeToAbsoluteUrl($uri, $currentUrl);

        // append session id if a session is active and URL rewriting is not disabled (strongly discouraged)
        if (defined('SID') && strlen(SID)) {                        // empty string if the session id was submitted in a cookie
            if (!ini_get_bool('session.use_only_cookies')) {        // TODO: check if session_destroy() resets SID
                $cookie       = session_get_cookie_params();
                $cookieDomain = strtolower(empty($cookie['domain']) ? $request->getHostname() : $cookie['domain']);
                $cookiePath   =            empty($cookie['path'  ]) ? '/'                     : $cookie['path'  ];
                $cookieSecure =                  $cookie['secure'];

                $target       = parse_url($url);
                $targetDomain = strtolower($target['host'  ]);
                $targetPath   =      empty($target['path'  ]) ? '/' : $target['path'];
                $targetSecure = strtolower($target['scheme']) == 'https';

                $subdomains = false;
                if ($cookieDomain[0] == '.') {                      // TODO: check if the leading dot is still required
                    $subdomains = true;                             //       (@see http://bayou.io/draft/cookie.domain.html)
                    $cookieDomain = substr($cookieDomain, 1);
                }

                if ($domainMatch = (preg_match('/\b'.$cookieDomain.'$/', $targetDomain) && ($cookieDomain==$targetDomain || $subdomains))) {
                    if ($pathMatch = strStartsWith($targetPath, $cookiePath)) {
                        if ($secureMatch = (!$cookieSecure || $targetSecure)) {
                            if (isset($target['fragment']))  $url  = strLeft($url, strlen($hash = '#'.$target['fragment']));
                            else if (strEndsWith($url, '#')) $url  = strLeft($url, strlen($hash = '#'));
                            else                             $hash = '';

                            $separator = !strContains($url, '?') ? '?' : '&';
                            $url .= $separator.SID.$hash;
                        }
                    }
                }
            }
        }

        // set the header
        header('Location: '.$url, true, $type);

        // terminate the script
        exit(0);
    }
252894
private function redirect(string $location, int $code): void
    {
        if (function_exists('redirect_with')) {
            redirect_with($location, $code); // http/sugars.php
        } elseif (!headers_sent()) {
            header('Location: '. $location, false, $code);
            $location = htmlspecialchars($location);
            die('Redirecting to <a href="'. $location .'">'. $location .'</a>'); // yes..
        }
    }
36647
public void redirect(String location) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Redirecting ({} {} to {}", "Found", HttpServletResponse.SC_FOUND, location);
        }
        try {
            response.sendRedirect(location);
        } catch (IOException ioException) {
            LOG.warn("Redirect failure", ioException);
        }
    }
1192104
public function set_redirect_location($location) {
	if (self::$send_status_headers == false && base::$debug) {
		trigger_error('location will not be send out unless response::$send_status_headers is true', E_USER_NOTICE);
	}
	
	$this->redirect_location = $location;
}
1371536
protected function _handleRedirect($type, $options) {
		if (isset($options[$type . 'RedirectUrl']) && $options[$type . 'RedirectUrl'] !== false) {
			$controller = $this->getController();
			$result = $controller->redirect($options[$type . 'RedirectUrl']);
			$this->_redirectResponse = $result;

			return $result;
		}

		$this->_redirectResponse = null;

		return false;
	}
1183548
public function redirect($uri, int $code = 302): ResponseInterface
    {
        if (!is_string($uri) && !$uri instanceof UriInterface) {
            throw new ResponseException("Redirect allowed only for string or UriInterface uris");
        }

        return $this->responseFactory->createResponse($code)->withHeader("Location", (string)$uri);
    }
139240
public function update(RedirectUriInterface $redirectUri): void
    {
        try {
            $now    = $this->ignoreException(function (): DateTimeImmutable {
                return new DateTimeImmutable();
            });
            $schema = $this->getDatabaseSchema();
            $this->updateResource($redirectUri->getIdentifier(), [
                $schema->getRedirectUrisClientIdentityColumn() => $redirectUri->getClientIdentifier(),
                $schema->getRedirectUrisValueColumn()          => $redirectUri->getValue(),
                $schema->getRedirectUrisUpdatedAtColumn()      => $now,
            ]);
            $redirectUri->setUpdatedAt($now);
        } catch (RepositoryException $exception) {
            $message = 'Client redirect URI update failed.';
            throw new RepositoryException($message, 0, $exception);
        }
    }
320323
public function redirect301($URL){
		if(empty($URL)){
			die('UNKNOWN ERROR');
			}
		if(DEBUG_MODE){
			echo('301 redirect: <a href="'.$URL.'">'.$URL.'</a>');
			return;
			}
		header($_SERVER['SERVER_PROTOCOL'].' 301 Moved Permanently');
		header('Location: '.$URL);
		}
145906
public static function token(String $uri = NULL, String $type = 'post')
    {
        Security::CSRFToken($uri, $type);
    }
409265
public function setType(string $type): void {
		if ($this->compiled) {
			throw new ResponseException("Attempt to alter response after compilation.", ResponseException::AFTER_COMPILE_ALTERATION);
		}
		
		$type = strtolower($type);
		
		if (!in_array($type, ["html", "json", "text", "redirect"])) {
			throw new ResponseException("Unexpected response type: $type.", ResponseException::UNKNOWN_RESPONSE_TYPE);
		}
		
		$this->type = $type;
	}
203333
public static function removeHeader($type) {
		
		if(false == is_string($type)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($type)), E_USER_ERROR);
		}

		header_remove($type);
	}
161497
public function redirect(string $url, int $httpResponseCode = 301, bool $exitAfter = true)
    {
        header('Location: ' . $url, true, $httpResponseCode);
        if ($exitAfter) {
            exit; // After a redirect, we must exit to halt any further script execution
        }
    }
102825
public function addHeader($header, $type = -1){
		if($header instanceof Header)
			$this->other_headers[] = $header;
		else
			$this->addAndCreateHeader($header, $type);
	}
765578
def redirect_response(self, url, permanent=False):
        
        if permanent:
            self.send_response(301)
        else:
            self.send_response(302)
        self.send_header("Location", url)
        self.end_headers()
673520
public void sendRedirect(String url) 
        throws IOException
    {
        if (url==null)
            throw new IllegalArgumentException();
        
        if (!URI.hasScheme(url))
        {
            StringBuffer buf = _servletHttpRequest.getHttpRequest().getRootURL();
            if (url.startsWith("/"))
                buf.append(URI.canonicalPath(url));
            else
            {
                String path=_servletHttpRequest.getRequestURI();
                String parent=(path.endsWith("/"))?path:URI.parentPath(path);
                url=URI.canonicalPath(URI.addPaths(parent,url));
                if (!url.startsWith("/"))
                    buf.append('/');
                buf.append(url);
            }
            
            url=buf.toString();
        }
        
        resetBuffer();
        
        _httpResponse.setField(HttpFields.__Location,url);
        _httpResponse.setStatus(HttpResponse.__302_Moved_Temporarily);
        complete();
    }
1360750
public function authRedirect($exit = true, $type = self::CODE_AUTH_TYPE, $state = null)
    {
        header('Location: ' . $this->getAuthUrl($type, $state));

        return $exit ? exit() : true;
    }
142213
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::MAX_REDIRECTS)
		{
			throw new Error\BadRequest("Exceeded maximum redirects");
		}

		$this->_redirects++;

		return $this->_dispatchRequest(
			new Request('GET', $locationUrl, $this->_headers));
	}