use Symfony\Component\HttpFoundation\RedirectResponse; $response = new RedirectResponse('/new-location'); $response->send();In this example, we create a new RedirectResponse object that has a URL of '/new-location'. We then send the response to the client. Package Library: Symfony HttpFoundation library.