redirectTo Helper method to allow redirection to a certain url.

@param mixed $location
@access public
@return void
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);
        }
    }
601419
public function removeLocation(Location $location): void
    {
        if (!$this->locations->contains($location)) {
            throw new \InvalidArgumentException(
                    'The location to remove does not exist');
        }
        $location->setWarehouse(null);
        $this->locations->removeElement($location);
    }
832383
protected function checkCategoryRedirect(Location $location): ?RedirectResponse
    {
        $content = $location->content;

        $internalRedirectContent = null;
        if (!$content->getField('internal_redirect')->isEmpty()) {
            $internalRedirectContent = $content->getFieldRelation('internal_redirect');
        }

        $externalRedirectValue = $content->getField('external_redirect')->value;

        if ($internalRedirectContent instanceof Content) {
            if ($internalRedirectContent->contentInfo->mainLocationId !== $location->id) {
                return new RedirectResponse(
                    $this->router->generate($internalRedirectContent),
                    RedirectResponse::HTTP_MOVED_PERMANENTLY
                );
            }
        } elseif ($externalRedirectValue instanceof UrlValue && !$content->getField('external_redirect')->isEmpty()) {
            if (mb_stripos($externalRedirectValue->link, 'http') === 0) {
                return new RedirectResponse($externalRedirectValue->link, RedirectResponse::HTTP_MOVED_PERMANENTLY);
            }

            return new RedirectResponse(
                $this->router->generate($this->getRootLocation()) . trim($externalRedirectValue->link, '/'),
                RedirectResponse::HTTP_MOVED_PERMANENTLY
            );
        }

        return null;
    }
802107
private function protectWithRedirect(Authentication $authentication, string $location): void
    {
        if (($this->authentication = $authentication->isLogged()) === false) {
            \header('Location: '.$location);
            throw new AuthenticationException('');
        }
    }
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);
        }
    }
812760
public function redirect($url='') {
		if(!preg_match('/^(?:\/|\\\\|\w:\\\\|\w:\/).*$/', $url) && !preg_match('/^[a-zA-Z0-9]*:\/\//', $url))#relative
			$url = $this->request->url->to($url);
		$this->setHeader('Location', $url);
		if($this->code === 200)
			$this->setCode(302);
		return $this;
	}
826574
public function isRedirect($location = null)
    {
        return in_array($this->statusCode, array(201, 301, 302, 303, 307, 308)) && (null === $location ?: $location == $this->getHeaderLine('Location'));
    }
1263372
public function redirect($url)
    {
        if (!$this->isValidUrl($url)) {
            $url = $this->generateUrl($url);
        }

        header('Location: '.$url);
    }
775258
public function redirect($location, $status = 302)
    {
        if (!$location) {
            return;
        }
        $this->status($status);
        $headers = $this->headers();
        $headers['Location'] = $location;
        return $this;
    }
76542
public function isRedirect($location = NULL) {

		return in_array(
				$this->statusCode,
				[
					self::HTTP_CREATED,
					self::HTTP_MOVED_PERMANENTLY,
					self::HTTP_FOUND,
					self::HTTP_SEE_OTHER,
					self::HTTP_TEMPORARY_REDIRECT,
					self::HTTP_PERMANENTLY_REDIRECT
				]
		) && (NULL === $location ?: $location == $this->headers->get('Location'));

	}
1344313
public function urlDoesNotRedirect($url)
    {
        if ('/' === $url) {
            $url = '';
        }

        // We must not follow all redirects, so save current situation,
        // force disable follow redirects, and revert at the end.
        $followsRedirects = $this->isFollowingRedirects();
        $this->followRedirects(false);

        $response       = $this->sendHeadAndGetResponse($url);

        if (null !== $response) {
            $responseCode   = $response->getStatus();
            $locationHeader = $response->getHeader('Location', true);

            // Check for 200 response code.
            $this->assertEquals(200, $responseCode, 'Response code was not 200.');

            // Check that destination URL does not try to redirect.
            // Somewhat redundant, as this should never appear with a 200 HTTP Status code anyway.
            $this->assertNull($locationHeader, 'Location header was found when it should not exist.');
        }

        $this->followRedirects($followsRedirects);
    }
978249
public function refreshSystemUrlAliasesForLocation(Location $location): void
    {
        $this->service->refreshSystemUrlAliasesForLocation($location);

        $this->signalDispatcher->emit(
            new UpdateLocationSignal(
                [
                    'contentId' => $location->contentId,
                    'locationId' => $location->id,
                    'parentLocationId' => $location->parentLocationId,
                ]
            )
        );
    }
79154
static function Redirect301($target, $noExit = false)
    {
        self::Redirect($target, self::REDIRECT_HEADER_301, $noExit);
    }
203794
public void redirect(final String location) {
    // set the header AND a meta refresh just in case
    response().headers().set("Location", location);
    sendReply(HttpResponseStatus.OK,
      new StringBuilder(
          "<html></head><meta http-equiv=\"refresh\" content=\"0; url="
           + location + "\"></head></html>")
         .toString().getBytes(this.getCharset())
    );
  }
1136331
public function indexLocation(Location $location)
    {
        $document = $this->mapper->mapLocation($location);

        $this->gateway->index($document);
    }
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);
		}
786348
public function redirect($url = null)
    {
        if (null === $url) {
            $url = $this->getServer('HTTP_ORIGIN');
        }
        ob_start();
        header('Location: ' . $url);
        ob_end_clean();
        Security::getInstance()->updateSession();
        exit(t('Redireccionando...'));
    }