system/Config/Services.php
public static function redirectResponse(App $config = null, bool $getShared = true)
	{
		if ($getShared)
		{
			return static::getSharedInstance('redirectResponse', $config);
		}

		if (! is_object($config))
		{
			$config = config(App::class);
		}

		$response = new RedirectResponse($config);
		$response->setProtocolVersion(static::request()
										  ->getProtocolVersion());

		return $response;
	}
public static function redirectResponse(App $config = null, bool $getShared = true)
	{
		if ($getShared)
		{
			return static::getSharedInstance('redirectResponse', $config);
		}

		if (! is_object($config))
		{
			$config = config(App::class);
		}

		$response = new RedirectResponse($config);
		$response->setProtocolVersion(static::request()
										  ->getProtocolVersion());

		return $response;
	}
The Redirect class provides nice way of working with redirects.

@param \Config\App $config
@param boolean     $getShared

@return \CodeIgniter\HTTP\Response