2

I tried to add IP address to for example : 172.20.0.3 I get this error : The provided host name is not valid for this server.

Here my settings

$settings['trusted_host_patterns'] = array(
  '^172\.20.\0.\3$',
  '^localhost$',
);
3
  • 1
    The HTTP host header will be a hostname, never an IP, so allowing IP addresses in trusted_host_patterns wouldn't make sense. They need to be hostnames or patterns to match hostnames as would be sent by the client – Clive Apr 18 '16 at 12:04
  • 1
    @Clive It would make sense if the client uses the IP address instead of the domain name, such as 127.0.0.1/index.php – Елин Й. Jun 29 '18 at 8:46
  • 1
    Yeah @ЕлинЙ., not sure what I meant by that – Clive Jun 29 '18 at 8:50
2

Your regex is incorrect. You placed the second and third \ after the . instead of before.

$settings['trusted_host_patterns'] = array(
  '^172\.20\.0\.3$',
  '^localhost$',
);

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.