Change the front page basing on the domain I need to write a custom module to map some static pages used as front page to some specific domains. For example, 


If domain is www.abc.com, the front page should be static_page_1
If the domain is www.bcd.com, the front page should be static_page_2


I have made a form for administrator users to enter the domain name and the static page they want as front page, but now I don't have any idea on where and how to write the code for detecting the domain name and set the front page.
Any information and suggestion will be very appreciated.
I've already find the answer by referring to Programmatically set the front page per site?. It is much simpler than the reference, because I just want to map the domain with my static page and I don't have a multisite drupal.
So, I just add an event subscriber and put all the mapping there.


  In the getSubscribedEvents method you need to set the weight to something greater than 30 which overrides the Page Cache and Dynamic Cache.


$events['kernel.request'] = ['kernel_request', '35'];



  Add this function in the same event subscriber file


public function kernel_request(Event $event) {
$config = \Drupal::configFactory()-&gt;getEditable('system.site');
$site_path = \Drupal::service('site.path');
$site_path = explode('/', $site_path);
$site_name = $site_path[1];

if ($site_name === 'site2' &amp;&amp; $event-&gt;getRequest()-&gt;getPathInfo() == '/') {
  $config-&gt;set('page.front', '/node/239')-&gt;save();
}
else {
  $config-&gt;set('page.front', '/home-content')-&gt;save();

}
}