1

Do I need to add my IP in settings.php and change settings.local.php if I'm only doing web host? Because I would like to fix the status report about no trusted host patterns. Thank you all for helping

1

No, you only need to add the hostname patterns in settings.php for how the site is being accessed, which normally isn't by IP. settings.local.php shouldn't be involved, as that is typically just for local development (I never adjust trusted patterns for local dev, just staging and production).

Essentially, the portion of code that handles this looks at the HTTP Host header, which is the hostname portion of the URL you requested (unless your webserver does canonical Host normalization, which is different that the rewrite rule for canonical URL). The IP address never comes into play, unless you browse directly to the a URL where the "hostname" portion is the IP.

  • Thank you mpdonadio what you mean by HTTP host header? I've confirmed my server name with support. – Rosina Ramos Novigesto Feb 24 '17 at 14:26
  • 1
    When the browser makes a request to the webserver, it includes a header to say what host it is trying to connect to. You should just need to adjust the hostname in the sample code in settings.php and uncomment it to make this work. – mpdonadio Feb 24 '17 at 14:33
  • thank you MPD that is a lot of information for me 1st how can I see that header and it is my server name? 2nd adjust hostmane is whiting the header is this host name? 3th I've uncomment it with / and /** in the beginning and end. Last time I get lock out with out hostname. – Rosina Ramos Novigesto Feb 25 '17 at 19:52
  • just this $settings['trusted_host_patterns'] = array( '^www\.example\.com$', ); is enough in case of web hosting ? – Rosina Ramos Novigesto Feb 25 '17 at 19:56
  • @RosinaRamosNovigesto Yup, that should work. If you browse to admin/reports/status/php, look for the "HTTP Headers Information" section. The Host line will be what you base that off of. – mpdonadio Feb 25 '17 at 20:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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