How to redirect to another page using the url alias? Here is my code where I am trying to redirect to a page using its url alias:

    $url= Url::fromUserInput('/thank_you_for_your_message')-&gt;toString();
    $form_state-&gt;setRedirect($url); 
    return;


and I get this error : Symfony\Component\Routing\Exception\RouteNotFoundException: Route "/thank_you_for_your_message" does not exist. in Drupal\Core\Routing\RouteProvider-&gt;getRouteByName()

Is the fromUserInput the correct way to redirect to an internal url alias?
Here you can see an example that works for me:

I use 'internal:url-alias'

use \Drupal\Core\Url;
...

$search_page = '/en/faith-community/find-a-parish';
$form_state-&gt;setRedirectUrl(Url::fromUri('internal:' . $search_page));