2

I have my drupal site running on localhost:8012. My url looks something like this : localhost:8012/d8multisite.com/ . I tried the following for enabling trusted_host_patterns.

$settings['trusted_host_patterns'] = array(
  '^d8multisite/.com$',
  '^localhost:8012//d8multisite/.com$',
  '^localhost/:8012//d8multisite/.com$',
  '^localhost/:8012//d8multisite/.com//$',
); 

I don't have much knowledge of regular expressions. I have been following the official Drupal 8 documentation for reference. Please guide me as to where am I going wrong. Any help would be much appreciated. Thanks.

1 Answer 1

2

The trusted_host_patterns settings is only for the domain name used to access the site. The regular expression you use must not include neither the port used to access the site, nor any path. If you access the site using as localhost, then the setting you should use is the following one.

$settings['trusted_host_patterns'] = array(
  '^localhost$',
);

If the site is accessible either as localhost or d8multisite.com, and you want to be able to access the site using both of them, then you should use the following setting.

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

Since the dot has a special meaning in a regular expression (it matches any single character), you need to escape it, so it is considered a normal character. To do so, you need to use . not /..

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.