After installing the “Drupal Content Management System (CMS)” on a server for the first time, an error warning appeared indicating that a feature in the basic installation, “Trusted Host Settings”, is not yet enabled, which introduces potential information security risks during site operation.

This warning prompt can be found on the http://SAMPLE.com/admin/reports/status page, with the following warning message (as shown in Fig. 1):

Trusted Host Settings Not enabled The trusted_host_patterns setting is not configured in settings.php. This can lead to security vulnerabilities. It is highly recommended that you configure this. See Protecting against HTTP HOST Header attacks for more information.

Fig.1, Drupal Fig.1, Drupal’s Error Message: “Trusted Host Settings”.

To resolve this issue, we need to reconfigure settings.php. This file is located in the /sites/default directory under the Drupal installation folder. Taking my own Linux setup as an example, the actual file path is $public_html/sites/default/.

The newly installed version in this case is Drupal 8.x, where you can find settings.php directly in that directory and proceed to edit it.

Linux command tip: The command to copy and rename a file is sudo cp OLD_FILE_NAME.php NEW_FILE_NAME.php.

If you cannot find this exact file, you should see default.settings.php in the same directory. Simply duplicate that file and rename it to settings.php to complete the setup.

Next, simply paste the following configuration code into settings.php (placed after <?php) to clear Drupal’s error warning and establish a secure internal binding between the Drupal system and the server, thereby hardening your website’s security:

$settings['trusted_host_patterns'] = array(
  '^vedfolnir\.com$',
  '^www\.vedfolnir\.com$',
  '^localhost$',
);

Note: Please replace the “vedfolnir” part in the snippet with your own domain name.

Recommended Server: Bluehost Server Provider.

✦ Independent Journalism · Reader Support ✦

Support Independent Perspectives & In-Depth Insights

Every thoughtful analysis and candid critique comes from our dedication to truth and quality. We choose not to follow sensational algorithms or clickbait headlines.

Sustaining independent research requires reader support. Make a one-time or monthly contribution, securely processed by Google.

Payments secured by Google · Manage or cancel anytime in your Google Account