How to configure Trusted_Host_Settings for subdomains?
The documentation does not give an example of a subdomain.
For example, I have an Add-On domain that points to website.info, but the subdomain is mainsite.com/website.info
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this communityHow to configure Trusted_Host_Settings for subdomains?
The documentation does not give an example of a subdomain.
For example, I have an Add-On domain that points to website.info, but the subdomain is mainsite.com/website.info
It's actually documented in settings.php
file as in examples:
Drupal 8.5.x
https://cgit.drupalcode.org/drupal/tree/sites/default/default.settings.php?h=8.5.x#n712
<?php
$settings['trusted_host_patterns'] = [
'^example\.com$', // Matches naked domain only.
'^.+\.example\.com$', // Matches any subdomains.
'^subdomain\.example\.com', // Matches a specific subdomain.
];
You can easily define any naked or sub-domain, as long as defined regex pattern matches them correctly.
trusted_host_patterns
setting. As the name suggests, it's for setting up trusted hostnames. If you don't know the difference between host and path, I also recommend reading up What is a URL? at MDN.