Hide path on frontpage redirect In a custom module i'm using an EventSubscriber to redirect different people to different frontpages. Below is the simplified code I'm using.
//GET PATH
$nid = 1;
$domain_url = \Drupal::service('path_alias.manager')-&gt;getAliasByPath('/node/'. $nid);

//FRONTPAGE REDIRECT
$response = new RedirectResponse($domain_url);
$event-&gt;setResponse($response);

The module is working but there is one detail I can't seem to solve.
For example on my website domain.com I have node/1 that has an alias path /home.
When going to domain.com it is, because of my module as expected, redirected to domain.com/home. But what I want is the url not to show the home part. Is it possible to show the content of /home but keeping the url domain.com?
You can add the path to your homepage from admin/config/system/site-information
And replace /node/1 to /home.
You don't need an even subscriber to do that.