src/mako/http/routing/Router.php
protected function redirectRoute(string $requestPath): Route
	{
		return new Route([], '', function(Request $request) use ($requestPath)
		{
			$url = $request->getBaseURL() . ($request->isClean() ? '' : '/' . $request->getScriptName()) . rtrim('/' . $request->getLanguagePrefix(), '/') . $requestPath . '/';

			$query = $request->getQuery()->all();

			if(!empty($query))
			{
				$url .= '?' . http_build_query($query, '', '&', PHP_QUERY_RFC3986);
			}

			return (new Redirect($url))->setStatus(301);
		});
	}
protected function redirectRoute(string $requestPath): Route
	{
		return new Route([], '', function(Request $request) use ($requestPath)
		{
			$url = $request->getBaseURL() . ($request->isClean() ? '' : '/' . $request->getScriptName()) . rtrim('/' . $request->getLanguagePrefix(), '/') . $requestPath . '/';

			$query = $request->getQuery()->all();

			if(!empty($query))
			{
				$url .= '?' . http_build_query($query, '', '&', PHP_QUERY_RFC3986);
			}

			return (new Redirect($url))->setStatus(301);
		});
	}
protected function redirectRoute ( string $ requestPath ) : Route { return new Route ( [ ] , '' , function ( Request $ request ) use ( $ requestPath ) { $ url = $ request -> getBaseURL ( ) . ( $ request -> isClean ( ) ? '' : '/' . $ request -> getScriptName ( ) ) . rtrim ( '/' . $ request -> getLanguagePrefix ( ) , '/' ) . $ requestPath . '/' ; $ query = $ request -> getQuery ( ) -> all ( ) ; if ( ! empty ( $ query ) ) { $ url .= '?' . http_build_query ( $ query , '' , '&' , PHP_QUERY_RFC3986 ) ; } return ( new Redirect ( $ url ) ) -> setStatus ( 301 ) ; } ) ; }
Returns a route with a closure action that redirects to the correct URL.

@param  string                   $requestPath The requested path
@return \mako\http\routing\Route
Returns a route with a closure action that redirects to the correct URL .