Drupal 8 -> redirect URL : 2 methods

<?php

class myController extends ControllerBase {

public function main(){

use Drupal\Core\Controller\ControllerBase;

use Symfony\Component\HttpFoundation\RedirectResponse;

 

return $this->redirect('my.route.name'); // method 1

return new RedirectResponse(\Drupal::url('my.route.name' ));  // method 2

}

}

?>

 

Method 2 verursacht zwei Weiterleitungen und generiert so eine Meldung:.

 

HTTP/1.0 302 Found Cache-Control: no-cache, private Date: Sun, 28 Jan 2018 00:41:09 GMT Location: /path/old Redirecting to /path/to/new-url

Vorschlag?

Neuen Kommentar schreiben

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.

Suche

Neueste Kommentare