Get route name of a views page in Drupal 8 & 9 using drupal console.
In this snippet I wanted to get the route route of a views page. The page is on /news.
drupal router:debug | grep '/news'
Now I can use this uri to set a redirection:
$redirect_url = Url::fromRoute('view.news.page_1'); $response = new RedirectResponse($redirect_url->toString(), 301); $event->setResponse($response);