Nov 09, 2020 in Drupal 8

I like drupal console a lot as a helper tool for development. In this snippet I wanted to get the route route of a views page. The page is on /news-events. 

drupal router:debug | grep '/news-events'

This returned:    /news-events

Now I can use this uri to set a redirection in my EventSubscriber:

    $redirect_url = Url::fromRoute('');
    $response = new RedirectResponse($redirect_url->toString(), 301);