If we have redirect to canonical host enabled, we need to honor it here.

@return \Concrete\Core\Routing\RedirectResponse|null
504014
public function handleCanonicalURLRedirection(SymfonyRequest $r, Site $site)
    {
        $globalConfig = $this['config'];
        $siteConfig = $site->getConfigRepository();

        if ($globalConfig->get('concrete.seo.redirect_to_canonical_url') && $siteConfig->get('seo.canonical_url')) {
            $requestUri = $r->getUri();

            $path = parse_url($requestUri, PHP_URL_PATH);
            $trailingSlash = substr($path, -1) === '/';

            $url = UrlImmutable::createFromUrl($requestUri, $trailingSlash);

            $mainCanonical = null;
            foreach (['seo.canonical_url', 'seo.canonical_url_alternative'] as $key) {
                $canonicalUrlString = $siteConfig->get($key);
                if (!$canonicalUrlString) {
                    continue;
                }
                $canonicalUrl = UrlImmutable::createFromUrl(
                    $canonicalUrlString,
                    (bool) $globalConfig->get('concrete.seo.trailing_slash')
                );
                // Set the parts of the current URL that are specified in the canonical URL, including host,
                // scheme, port. Set scheme first so that our port can use the magic "set if necessary" method.
                $canonical = $url
                    ->setScheme($canonicalUrl->getScheme()->get())
                    ->setHost($canonicalUrl->getHost()->get())
                    ->setPort($canonicalUrl->getPort()->get())
                ;
                // Now we have our current url, swapped out with the important parts of the canonical URL.
                // If it matches, we're good.
                if ($canonical == $url) {
                    return null;
                }
                if ($mainCanonical === null) {
                    $mainCanonical = $canonical;
                }
            }

            $response = new RedirectResponse($mainCanonical, '301');

            return $response;
        }
    }
1130249
public function isRedirect()
    {
        $request = $this->request->getData();
        $response = $this->getData();

        return
            $request['opcode'] === 0 &&
            $response['extended_status'] === '3DSECURE';
    }
722045
public function getRedirectUri()
	{
		return null === $this->loginAgentUrl ? $this->callbackUrl : ($this->loginAgentUrl . '?' . http_build_query(array('redirect_uri'=>$this->callbackUrl)));
	}
64548
public function linkAccount() {
    $sdk = $this->getSdk();

    if ($sdk instanceof RedirectResponse) {
      return $sdk;
    }

    $this->authManager->setSdk($sdk);
    $url = $this->authManager->getAuthenticationUrl('link');

    return new TrustedRedirectResponse($url);
  }
1045853
public function handler(): Response
    {
        if ($this->redirect) {
            return response(null, 302, ['Location' => $this->redirect]);
        } elseif ($this->request->query->has('error')) {
            return view('error.twig', [
                'error' => $this->request->query->get('error'),
                'message' => $this->request->query->get('message')
            ]);
        } else {
            $this->addAssets();
            return view($this->template, $this->data);
        }
    }
389856
public function redirect()
    {
        $state = null;

        if ($this->usesState()) {
            $this->request->session()->put('state', $state = $this->getState());
        }

        return new RedirectResponse($this->getAuthUrl($state));
    }
1131074
protected function requestUrl()
    {
        if (!empty($_SERVER['REQUEST_URI']) && $_SERVER['REQUEST_URI'] !== '/') {
            $request = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
        }

        return add_query_arg('redirect_to', urlencode($request ?? $this->url()), $this->loginUrl());
    }
42185
public function logout()
    {
        $controller = $this->getController();
        $result = $this->getAuthenticationService()->clearIdentity(
            $controller->request,
            $controller->response
        );

        $controller->request = $result['request'];
        $controller->response = $result['response'];

        $this->dispatchEvent('Authentication.logout', [], $controller);

        $logoutRedirect = $this->getConfig('logoutRedirect');
        if ($logoutRedirect === false) {
            return null;
        }

        return Router::normalize($logoutRedirect);
    }
1046686
private function getRedirects()
    {
        $httpWithJsBackup = [
            $this->httpRedirect,
            $this->jsRedirect
        ];

        return $this->redirect->isTypeJavaScript() ? [$this->jsRedirect] : $httpWithJsBackup;
    }
1339955
protected function redirectAfterUpdate()
    {
        merchant_toastr(trans('merchant.update_succeeded'));

        $url = Input::get(Builder::PREVIOUS_URL_KEY) ?: $this->resource(-1);

        return redirect($url);
    }
329627
protected function getRedirectUrl()
    {
        $url = $this->redirector->getUrlGenerator();

        if ($this->redirect) {
            return $url->to($this->redirect);
        } elseif ($this->redirectRoute) {
            return $url->route($this->redirectRoute);
        } elseif ($this->redirectAction) {
            return $url->action($this->redirectAction);
        }

        return $url->previous();
    }
276636
public function redirect()
    {
        $state = null;

        if ($this->usesState()) {
            $this->request->getSession()->set('state', $state = Str::random(40));
        }

        return new RedirectResponse($this->getAuthUrl($state));
    }
395268
public function resolveAllAction()
    {
        $this->getEntityManager()->getRepository(Exception::class)->markAllAsResolved();

        $indexUrl = $this->getAdminListConfigurator()->getIndexUrl();

        return new RedirectResponse(
            $this->generateUrl(
                $indexUrl['path'],
                isset($indexUrl['params']) ? $indexUrl['params'] : array()
            )
        );
    }
733452
protected function getRedirectUri()
    {
        if (isset($_POST['redirect'])) {
            return $_POST['redirect'];
        }
        if (isset($_GET['redirect'])) {
            return $_GET['redirect'];
        }
        return \Staq::App()->getCurrentUri();
    }
1301747
public function remoteAddress(): ?string
    {
        $serverParams = $this->request()->getServerParams();

        return isset($serverParams['REMOTE_ADDR']) ? $serverParams['REMOTE_ADDR'] : null;
    }
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...'));
    }
649586
public function activateAction()
    {
        $object = $this->getObject();
        
        if (method_exists($object, 'setActive') && method_exists($object, 'getActive')) {
            $object->setActive(($object->getActive()==1) ? 0 : 1);
        }
        
        $this->admin->update($object);        
        
        return new RedirectResponse($this->admin->generateUrl('list'));
    }