문제

How can I redirect visitors to a specific page based on the sub-domain? For example:

  • www.site.com goes to frontpage
  • checklist.site.com goes to checklist.site.com/checklist

My server is set to work with a wildcard (*.site.com). All sub-domains point to the same Drupal site.

I found Redirect based on query string about redirecting in Drupal 8, but I am not able to achieve what I want following what reported there.

도움이 되었습니까?

해결책

The linked post points in the right directions, but contains a lot of code you don't need. Use this change record https://www.drupal.org/node/2013014 instead and check $request->getHost():

  public function checkForRedirection(GetResponseEvent $event) {
    if ($event->getRequest()->getHost() == '...') {
      $event->setResponse(new RedirectResponse('http://example.com/foo/'));
    }
  }

For a non-coding solution you can try Redirect Domain, a submodule of Redirect.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 drupal.stackexchange
scroll top