How do I redirect to an external URL?
With a route name on a Controller:

use Drupal\Core\Controller\ControllerBase;

class MyControllerClass extends ControllerBase {

  public function foo() {
    //...
    return $this-&gt;redirect('user.page');
  }
}


With an absolute URL:

return new RedirectResponse('https://google.com');


On a form RedirectResponse doesn't work, then:

With a route name:

public function submitForm(array &amp;$form, FormStateInterface $form_state) {
  //...

  $form_state-&gt;setRedirect('user.page');
}


With an absolute URL:

public function submitForm(array &amp;$form, FormStateInterface $form_state) {
  //...

  $form_state-&gt;setResponse(new TrustedRedirectResponse('https://google.com', 302));
  // You can change the response code from 302 to whatever you need
}