Returns the url to redirect to based on current route.
If $redirect is set and the option to use redirect is set to true, it will return the $redirect url.

@param  string $currentRoute
@param  bool   $redirect
@return mixed
332388
private function getRedirect($currentRoute, $redirect = false)
    {
        $useRedirect = $this->options->getUseRedirectParameterIfPresent();
        $routeExists = ($redirect && $this->routeExists($redirect));
        if (!$useRedirect || !$routeExists) {
            $redirect = false;
        }

        switch ($currentRoute) {
            case 'zfcuser/login':
            case 'scn-social-auth-user/login':
            case 'scn-social-auth-user/register':
            case 'scn-social-auth-user/authenticate/provider':
            case 'scn-social-auth-user/add-provider/provider':
                $route = ($redirect) ?: $this->options->getLoginRedirectRoute();

                return $this->router->assemble(array(), array('name' => $route));
                break;
            case 'zfcuser/logout':
            case 'scn-social-auth-user/logout':
                $route = ($redirect) ?: $this->options->getLogoutRedirectRoute();

                return $this->router->assemble(array(), array('name' => $route));
                break;
            default:
                return $this->router->assemble(array(), array('name' => 'zfcuser'));
        }
    }
839748
public static function redirect($url = false){
		
		if($url) {

			if(strpos($url,'http') === false && strpos($url,'https') === false) {
				$url = BASE_URL . $url;
			}

			header('Location: ' . $url);
			exit;
		}

		return false;
	}
382483
public function setRedirectUrl($redirect = null, $key = null) {
		if (empty($redirect)) {
			$redirect = $this->_controller->request->referer(true);
		} elseif ($redirect === true) {
			$redirect = $this->_controller->request->here(true);
		}
		if (empty($redirect) || $this->_controller->request->is('popup') ||
			$this->_controller->request->is('print')) {
			return false;
		}
		$cacheKey = $this->_getSessionKeyRedirect($key);
		$data = CakeSession::read($cacheKey);
		if (!empty($data) && (md5((string)$data) === md5((string)$redirect))) {
			return false;
		}

		return CakeSession::write($cacheKey, $redirect);
	}
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();
    }
606532
public function getCurrentRouteMatch() {
    if (empty($this->currentRouteMatch)) {
      $this->currentRouteMatch = \Drupal::service('current_route_match');
    }
    return $this->currentRouteMatch;
  }
207364
function redirect($to, $options = [])
    {
        return function(\Silex\Application $app) use ($to, $options) {
            $headers  = (array) @$options['headers'];
            $status   = @$options['status'] ?: 302;
            $params   = (array) @$options['params'];
            $absolute = @$options['absolute'] ?: false;

            # Generate URL if the first argument is an existing route name
            if ($route = $app['routes']->get($to)) {
                $to = $app['url_generator']->generate($to, $params, $absolute);
            }

            return new RedirectResponse($to, $status, $headers);
        };
    }
394391
protected function verifyRedirect($redirectUrl, $options)
    {
        if (strlen($redirectUrl) > 2048) {
            throw new \Exception('Too long redirectUrl argument passed');
        }
        if ($redirectUrl !== '') {
            // The below check is to prevent possible redirect attack
            // (if someone tries to redirect user to another domain).
            $uri = new Uri($redirectUrl);
            if (!$uri->isValid() || $uri->getHost() !== null) {
                throw new \Exception('Incorrect redirect URL: ' . $redirectUrl);
            }
            $options = ArrayUtils::merge($options, ['query' => ['redirect' => $redirectUrl]]);
        }
        return $options;
    }
972644
public function getRedirectToRoute($route, $parameters = [], $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH, $status = Response::HTTP_FOUND, $routeFragment = null)
    {
        $url = $this->getRouter()->generate($route, $parameters, $referenceType);
        if (null !== $routeFragment) {
            $url = sprintf('%s#%s', $url, $routeFragment);
        }

        return new RedirectResponse($url, $status);
    }
739486
function uri($current = false)
    {
        if ($current && $this->is_changed('uri')){
            return $this->changes('uri');
        }
        return $this->_attributes['uri'];
    }
1278158
function getRedirectRoute(that, path, newRoutePath, newRoutes, routeDivergenceIndex) {
        if(newRoutes.length > 0) {
            var redirectInfo = newRoutes[newRoutes.length-1].route.redirectInfo
        } else {
            var redirectInfo = newRoutePath[routeDivergenceIndex-1].route.redirectInfo
        }

        if(redirectInfo !== undefined) {
            var newPathToEmit = redirectInfo.path
            if(redirectInfo.emitOldPath)
                newPathToEmit = path

            try {
                var newPath = getPathFromInput(that.transform, redirectInfo.path)
            } catch(e) {
                if(e.message === 'pathNotArray') {
                    throw new Error("A route passed to `redirect` must be an array")
                } else {
                    throw e
                }
            }

            return getNewRouteInfo(that, newRoutePath, newPath, newPathToEmit)
        }

        return false
    }
336507
protected function getBatchRedirectUrl() : string
    {
        // default url
        $result = ['plugin' => $this->plugin, 'controller' => $this->name, 'action' => 'index'];

        $currentUrl = $this->request->getEnv('HTTP_ORIGIN') . $this->request->getRequestTarget();
        // if referer does not match current url, redirect to referer (delete action)
        if (false === strpos($this->referer(), $currentUrl)) {
            $result = $this->referer();
        }

        // use batch redirect url if provided (edit action)
        if ($this->request->getData('batch.redirect_url')) {
            $result = $this->request->getData('batch.redirect_url');
        }

        return Router::url($result);
    }
1331303
private function createWildcardRoute(Redirect $redirect)
    {
        $origin = $redirect->getOrigin();
        $target = $redirect->getTarget();
        $url = $this->context->getPathInfo();

        $origin = substr($origin, 0, -1);
        $target = substr($target, 0, -1);
        $pathInfo = str_replace($origin, $target, $url);

        $this->context->setPathInfo($pathInfo);

        return new Route(
            $url, array(
                    '_controller' => 'FrameworkBundle:Redirect:urlRedirect',
                    'path' => $url,
                    'permanent' => $redirect->isPermanent(),
                ));
    }
454478
protected function updateDependingRedirects(RedirectInterface $newRedirect)
    {
        /** @var $existingRedirectForSourceUriPath Redirect */
        $existingRedirectForSourceUriPath = $this->redirectRepository->findOneBySourceUriPathAndHost($newRedirect->getSourceUriPath(), $newRedirect->getHost(), false);
        if ($existingRedirectForSourceUriPath !== null) {
            $this->removeAndLog($existingRedirectForSourceUriPath, sprintf('Existing redirect for the source URI path "%s" removed.', $newRedirect->getSourceUriPath()));
            $this->routerCachingService->flushCachesForUriPath($existingRedirectForSourceUriPath->getSourceUriPath());
        }

        /** @var $existingRedirectForTargetUriPath Redirect */
        $existingRedirectForTargetUriPath = $this->redirectRepository->findOneBySourceUriPathAndHost($newRedirect->getTargetUriPath(), $newRedirect->getHost(), false);
        if ($existingRedirectForTargetUriPath !== null) {
            $this->removeAndLog($existingRedirectForTargetUriPath, sprintf('Existing redirect for the target URI path "%s" removed.', $newRedirect->getTargetUriPath()));
            $this->routerCachingService->flushCachesForUriPath($existingRedirectForTargetUriPath->getSourceUriPath());
        }

        $obsoleteRedirectInstances = $this->redirectRepository->findByTargetUriPathAndHost($newRedirect->getSourceUriPath(), $newRedirect->getHost());
        /** @var $obsoleteRedirect Redirect */
        foreach ($obsoleteRedirectInstances as $obsoleteRedirect) {
            if ($obsoleteRedirect->getSourceUriPath() === $newRedirect->getTargetUriPath()) {
                $this->redirectRepository->remove($obsoleteRedirect);
            } else {
                $obsoleteRedirect->setTargetUriPath($newRedirect->getTargetUriPath());
                $this->redirectRepository->update($obsoleteRedirect);
            }
        }
    }
934018
protected function getRedirectUrl($context = null)
    {
        $redirectContext = explode('-', $context, 2)[0];
        $redirectSource = ends_with($context, '-close') ? 'redirectClose' : 'redirect';

        // Get the redirect for the provided context
        $redirects = [$context => $this->getConfig("{$redirectContext}[{$redirectSource}]", '')];

        // Assign the default redirect afterwards to prevent the
        // source for the default redirect being default[redirect]
        $redirects['default'] = $this->getConfig('defaultRedirect', '');

        if (empty($redirects[$context])) {
            return $redirects['default'];
        }

        return $redirects[$context];
    }
688743
public function getLogoutUrl ($redirectTo = null)
		{
			if (empty($redirectTo))
				return $this->_logoutUrl;
			else
				return $this->_logoutUrl . '?next=' . urlencode($redirectTo);
		}
772736
public function getRedirect($url)
    {
        $pages = $this->getRedirects();
        $url = $this->normalizeUrl($url);

        if (isset($pages[$url])) {
            return $pages[$url];
        }
    }
676057
def _get_redirect_url(self, request):
        
        if 'next' in request.session:
            next_url = request.session['next']
            del request.session['next']
        elif 'next' in request.GET:
            next_url = request.GET.get('next')
        elif 'next' in request.POST:
            next_url = request.POST.get('next')
        else:
            next_url = request.user.get_absolute_url()
        if not next_url:
            next_url = '/'
        return next_url