2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Drupal8 ドメイン変更で混乱した備忘

Last updated at Posted at 2018-09-19

The provided host name is not valid for this server.

スクリーンショット 2018-09-19 19.18.05.png
この画面。

ドキュメント通り設定したのに…

https://www.drupal.org/docs/8/install/trusted-host-settings
こちらにある通り、config.phpを書き換えましたが、どうもみてくれないようでした。

ゴリ押し

drupal-8.5.5/core/lib/Drupal/Core/DrupalKernel.php
  protected function initializeSettings(Request $request) {
    $site_path = static::findSitePath($request);
    $this->setSitePath($site_path);
    $class_loader_class = get_class($this->classLoader);
    Settings::initialize($this->root, $site_path, $this->classLoader);

    // Initialize our list of trusted HTTP Host headers to protect against
    // header attacks.
    $host_patterns = Settings::get('trusted_host_patterns', []);
    # ホワイトリスト追加 START
    $host_patterns[] = '^www\.example\.com$';
    $host_patterns[] = '^example\.com$';
    # ホワイトリスト追加 END
    if (PHP_SAPI !== 'cli' && !empty($host_patterns)) {
      if (static::setupTrustedHosts($request, $host_patterns) === FALSE) {
        throw new BadRequestHttpException('The provided host name is not valid for this server.');
      }
    }

下記の部分です

DrupalKernel.php
    # ホワイトリスト追加 START
    $host_patterns[] = '^www\.example\.com$';
    $host_patterns[] = '^example\.com$';
    # ホワイトリスト追加 END

Drupal8詳しい人いたら教えてください…
ググっても答えが見つかりませんでした。config.phpを読まないという。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?